View difference between Paste ID: Cf3GcEZV and WLDTncCm
SHOW: | | - or go back to the newest paste.
1
    from feature_server.scripts.avx import AVX
2
    import json
3
    from pyspades.common import make_color
4
5
    def rotate_all(dct, fm, to):
6
        amt = (to - fm) % 4
7
        if amt == 0:
8
            rot = lambda t: t
9
        elif amt == 1:
10
            rot = lambda t: (-t[1],  t[0]) + t[2:]
11
        elif amt == 2:
12
            rot = lambda t: (-t[0], -t[1]) + t[2:]
13
        elif amt == 3:
14
            rot = lambda t: ( t[1], -t[0]) + t[2:]
15
        if isinstance(dct, dict):
16
            dct = dct.iteritems()
17
        for k,v in dct:
18
            yield rot(k), v
19
20
    def shift_origin(dct, new_origin):
21
        new_origin = tuple(new_origin)
22
        shift = lambda tpl: tuple(a-b for a,b in zip(tpl, new_origin))
23
        if isinstance(dct, dict):
24
            dct = dct.iteritems()
25
        for k,v in dct:
26
            yield shift(k), v
27
    
28
    def build(px, py, structure, default_color):
29
        if isinstance(structure, dict):
30
            structure = structure.iteritems()
31
        pz = int(hmap.get(px,py)*63)
32-
        for xyz, color in structure.iteritems():
32+
        for xyz, color in structure:
33
            x, y, z = xyz
34
            x, y, z = x + px, y + py, z + pz
35
            vxl.set_point(x, y, z, color or default_color)
36
            #if color is none, use default_color
37
38
    penis_settings = json.load(open('./qb/penis.avx.txt', 'r'))
39
    penis = AVX.fromfile('./qb/penis.avx').tosparsedict()
40
    penis = dict(shift_origin(penis, penis_settings['origin']))
41-
    rotate_all(penis,0,random.randint(0,3))
41+
42
    for x in xrange(0, bmap.width):
43
        for y in xrange(0, bmap.height):
44
            if bmap.get_repeat(x, y) is hill_biome:
45
                left, top, right, bottom = bmap.rect_of_point(x,y)
46
                for ct in xrange(random.randint(1,3)):
47
                    build(random.randint(left,right)
48-
                    build(random.randint(left,right),
48+
                        , random.randint(top,bottom) 
49-
                     random.randint(top,bottom), penis, (255,0,216))
49+
                        , rotate_all(penis, 0, random.randint(0,3)) #rotate it different every time
50
                        , (255,0,216))