Example #1
0
def mesh_test_get_draw_fn():
    x = mesh.c_mesh()
    bezier_list = []
    for (p0, c0, p1) in [
        ((100, 100), (110, 90), (150, 50)),
        ((150, 50), (150, 150), (200, 100)),
        ((200, 100), (150, 150), (200, 200)),
        ((200, 200), (175, 175), (150, 150)),
        ((150, 150), (125, 125), (100, 100)),
    ]:
        p0 = bezier.c_point(coords=p0)
        c0 = bezier.c_point(coords=c0)
        p1 = bezier.c_point(coords=p1)
        bezier_list.append(bezier.c_bezier2(pts=(p0, c0, p1)))
        pass
    font_dir = "../../fonts/"
    fontname = "beneg___"
    #fontname = "SF Old Republic SC Bold"
    glyphname = "ampersand"
    glyphname = "dollar"
    glyphname = "A"
    glyphname = "C"
    glyphname = "m"
    #glyphname = "A"
    #glyphname = "N"
    #glyphname = "F"
    #glyphname = "P"
    font.c_font.convert_ttf_to_ttx(font_dir + fontname + ".ttf",
                                   font_dir + "a.ttx")
    f = font.c_font("benegraphic").load_from_ttx(font_dir + "a.ttx")
    contours = f.create_bezier_lists(glyphname)
    x = f.get_mesh(glyphname, straightness=50)
    bbox = f.get_bbox(glyphname)
    pygame.font.init()
    pyfont = pygame.font.SysFont(u'palatino', 10)

    #pyfont=None
    def draw_fn(screen):
        size = 800.0
        scale = size / bbox[2]
        if 100.0 / bbox[3] < scale: scale = size / bbox[3]
        scale = (scale, -scale)
        offset = (0, size)
        draw_triangles(screen,
                       x.triangles,
                       scale=scale,
                       offset=offset,
                       font=pyfont)
        draw_contour(screen, x, scale=scale, offset=offset)

    return draw_fn
Example #2
0
    def opengl_post_init(self):
        from gjslib.math import bezier
        from ctypes import sizeof, c_float, c_void_p, c_uint

        pts = []
        for coords in self.patch:
            pts.append( bezier.c_point(coords=coords) )
            pass
        bp = bezier.c_bezier_patch( pts=pts )

        float_size = sizeof(c_float)
        vertex_offset    = c_void_p(0 * float_size)
        normal_offset    = c_void_p(3 * float_size)
        record_len       = 6 * float_size
        data_array = []
        n = 14
        for i in range(n+1):
            for j in range(n+1):
                data_array.append( bp.coord(i/(n+0.0),j/(n+0.0)).get_coords(scale=(2.0,2.0,2.0),offset=(-1.,-1.0,.0)) )
                data_array.append( bp.normal(i/(n+0.0),j/(n+0.0)).get_coords() )
                pass
            pass

        vertices = vbo.VBO( data=numpy.array(data_array, dtype=numpy.float32) )
        index_list = []
        if self.use_primitive_restart:
            glEnable(GL_PRIMITIVE_RESTART) 
            pass
        for j in range(n):
            for i in range(n+1):
                index_list.append( i+j*(n+1) )
                index_list.append( i+(j+1)*(n+1) )
                pass
            if j<(n-1):
                if self.use_primitive_restart:
                    index_list.append( 255 )
                    pass
                else:
                    index_list.append( (n)+(j+1)*(n+1) )
                    index_list.append( (n)+(j+1)*(n+1) )
                    index_list.append( (j+1)*(n+1) )
                    index_list.append( (j+1)*(n+1) )
                    pass
            pass
    
        print index_list
        indices = vbo.VBO( data=numpy.array( index_list, dtype=numpy.uint8),
                           target=GL_ELEMENT_ARRAY_BUFFER )
        vertices.bind()
        indices.bind()
        self.opengl_surface["vertices"] = vertices
        self.opengl_surface["indices"] = indices
        self.opengl_surface["vertex_offset"] = vertex_offset
        self.opengl_surface["normal_offset"] = normal_offset
        self.opengl_surface["record_len"] = record_len
        pass
Example #3
0
def mesh_test_get_draw_fn():
    x = mesh.c_mesh()
    bezier_list = []
    for (p0,c0,p1) in [ ( (100,100), (110,90), (150, 50) ),
                        ( (150, 50), (150,150), (200,100) ),
                        ( (200,100), (150,150), (200,200) ),
                        ( (200,200), (175,175), (150,150) ),
                        ( (150,150), (125,125), (100,100) ),
                    ]:
        p0 = bezier.c_point(coords=p0)
        c0 = bezier.c_point(coords=c0)
        p1 = bezier.c_point(coords=p1)
        bezier_list.append(bezier.c_bezier2(pts=(p0,c0,p1)))
        pass
    font_dir = "../../fonts/"
    fontname = "beneg___"
    #fontname = "SF Old Republic SC Bold"
    glyphname = "ampersand"
    glyphname = "dollar"
    glyphname = "A"
    glyphname = "C"
    glyphname = "m"
    #glyphname = "A"
    #glyphname = "N"
    #glyphname = "F"
    #glyphname = "P"
    font.c_font.convert_ttf_to_ttx( font_dir+fontname+".ttf", font_dir+"a.ttx" )
    f = font.c_font("benegraphic").load_from_ttx( font_dir+"a.ttx")
    contours = f.create_bezier_lists( glyphname )
    x = f.get_mesh( glyphname, straightness=50 )
    bbox = f.get_bbox(glyphname )
    pygame.font.init()
    pyfont = pygame.font.SysFont(u'palatino',10)
    #pyfont=None
    def draw_fn( screen ):
        size = 800.0
        scale = size/bbox[2]
        if 100.0/bbox[3]<scale: scale=size/bbox[3]
        scale = ( scale, -scale )
        offset=( 0, size)
        draw_triangles( screen, x.triangles, scale=scale, offset=offset, font=pyfont )
        draw_contour( screen, x, scale=scale, offset=offset )
    return draw_fn
Example #4
0
def polygon_test_get_draw_fn():
    x = c_polygon()
    bezier_list = []
    for (p0, c0, p1) in [
        ((100, 100), (110, 90), (150, 50)),
        ((150, 50), (150, 150), (200, 100)),
        ((200, 100), (150, 150), (200, 200)),
        ((200, 200), (175, 175), (150, 150)),
        ((150, 150), (125, 125), (100, 100)),
    ]:
        p0 = bezier.c_point(coords=p0)
        c0 = bezier.c_point(coords=c0)
        p1 = bezier.c_point(coords=p1)
        bezier_list.append(bezier.c_bezier2(pts=(p0, c0, p1)))
        pass
    f = font.c_font("benegraphic").load_from_ttx("/Users/gstark_old/a.ttx")
    bezier_list = f.create_bezier_lists("ampersand")[0]
    print bezier_list
    x.from_bezier_list(bezier_list=bezier_list, straightness=10)
    #print x
    print "Normalizing"
    x.normalize()
    print x.__repr__(verbose=True)
    print "Filling"
    x.fill_convex_hull_with_triangles()
    print x.__repr__(verbose=True)
    x.check_consistent()
    print "Shorten"
    i = 0
    while x.shorten_quad_diagonals(i > 100) > 0:
        i += 1
        if i > 101: break
        pass
    print "broken out after", i
    x.check_consistent()

    def draw_fn(screen):
        draw_triangles(screen, x.triangles)
        draw_contour(screen, x)

    return draw_fn
Example #5
0
def polygon_test_get_draw_fn():
    x = c_polygon()
    bezier_list = []
    for (p0,c0,p1) in [ ( (100,100), (110,90), (150, 50) ),
                        ( (150, 50), (150,150), (200,100) ),
                        ( (200,100), (150,150), (200,200) ),
                        ( (200,200), (175,175), (150,150) ),
                        ( (150,150), (125,125), (100,100) ),
                    ]:
        p0 = bezier.c_point(coords=p0)
        c0 = bezier.c_point(coords=c0)
        p1 = bezier.c_point(coords=p1)
        bezier_list.append(bezier.c_bezier2(pts=(p0,c0,p1)))
        pass
    f = font.c_font("benegraphic").load_from_ttx("/Users/gstark_old/a.ttx")
    bezier_list = f.create_bezier_lists( "ampersand" )[0]
    print bezier_list
    x.from_bezier_list( bezier_list=bezier_list, straightness=10 )
    #print x
    print "Normalizing"
    x.normalize()
    print x.__repr__(verbose=True)
    print "Filling"
    x.fill_convex_hull_with_triangles()
    print x.__repr__(verbose=True)
    x.check_consistent()
    print "Shorten"
    i=0
    while x.shorten_quad_diagonals(i>100)>0:
        i+=1
        if i>101:break
        pass
    print "broken out after",i
    x.check_consistent()
    def draw_fn( screen ):
        draw_triangles( screen, x.triangles )
        draw_contour( screen, x )
    return draw_fn
Example #6
0
 def create_bezier_lists(self):
     bezier_lists = []
     for c in self.glyph:
         beziers = []
         i = 0
         p0 = c0 = p1 = None
         while i < len(c):
             (p0, c0, p1) = (c0, p1, bezier.c_point(coords=c[i]))
             if ((i & 1) == 0) and p0 is not None:
                 beziers.append(bezier.c_bezier2(pts=(p0, c0, p1)))
                 pass
             i += 1
             pass
         bezier_lists.append(beziers)
         pass
     return bezier_lists
Example #7
0
 def create_bezier_lists( glyph ):
     bezier_lists = []
     for c in glyph.glyph["contours"]:
         beziers = []
         i = 0
         p0 = c0 = p1 = None
         while i<len(c):
             (p0,c0,p1) = (c0,p1,bezier.c_point(coords=c[i]))
             if ((i&1)==0) and p0 is not None:
                 beziers.append( bezier.c_bezier2( pts=(p0,c0,p1) ) )
                 pass
             i += 1
             pass
         bezier_lists.append(beziers)
         pass
     return bezier_lists
Example #8
0
 def optimize(self, split_max_areas=3):
     min_length = 1E-6
     min_area = 1E-8
     self.mesh.map_contours_to_mesh()
     self.mesh.normalize()
     self.mesh.fill_convex_hull_with_triangles()
     self.mesh.remove_small_lines(min_length=min_length)
     self.mesh.remove_small_area_triangles(min_area=min_area)
     for i in range(10):
         if self.mesh.shorten_quad_diagonals() == 0: break
         pass
     for i in range(10):
         self.mesh.ensure_contours_on_mesh()
         self.mesh.shorten_quad_diagonals()
         self.mesh.remove_small_lines(min_length=min_length)
         self.mesh.remove_small_area_triangles(min_area=min_area)
         pass
     self.mesh.ensure_contours_on_mesh()
     self.mesh.assign_winding_order_to_contours()
     self.mesh.assign_winding_order_to_mesh()
     if split_max_areas <= 0:
         return
     large_areas = self.mesh.find_large_area_triangle_centroids(max_area=0)
     #print large_areas
     l = []
     for (a, x, y) in large_areas:
         l.append(a)
         pass
     l.sort()
     max_area = l[len(l) /
                  2] / 2.0  # find median area of l, and divide by 2
     for (a, x, y) in large_areas:
         if (a > max_area):
             self.mesh.add_point(c_point((x, y)))
             #print "Adding point",(x,y)
             pass
         pass
     self.mesh.reset_triangles()
     self.mesh.reset_lines()
     return self.optimize(split_max_areas=split_max_areas - 1)
     pass
Example #9
0
 def optimize(self, split_max_areas=3):
     min_length = 1E-6
     min_area = 1E-8
     self.mesh.map_contours_to_mesh()
     self.mesh.normalize()
     self.mesh.fill_convex_hull_with_triangles()
     self.mesh.remove_small_lines(min_length=min_length)
     self.mesh.remove_small_area_triangles( min_area=min_area)
     for i in range(10):
         if self.mesh.shorten_quad_diagonals()==0: break
         pass
     for i in range(10):
         self.mesh.ensure_contours_on_mesh()
         self.mesh.shorten_quad_diagonals()
         self.mesh.remove_small_lines(min_length=min_length)
         self.mesh.remove_small_area_triangles(min_area=min_area)
         pass
     self.mesh.ensure_contours_on_mesh()
     self.mesh.assign_winding_order_to_contours()
     self.mesh.assign_winding_order_to_mesh()
     if split_max_areas<=0:
         return
     large_areas = self.mesh.find_large_area_triangle_centroids(max_area=0)
     #print large_areas
     l = []
     for (a,x,y) in large_areas:
         l.append(a)
         pass
     l.sort()
     max_area = l[len(l)/2]/2.0 # find median area of l, and divide by 2
     for (a,x,y) in large_areas:
         if (a>max_area):
             self.mesh.add_point(c_point((x,y)))
             #print "Adding point",(x,y)
             pass
         pass
     self.mesh.reset_triangles()
     self.mesh.reset_lines()
     return self.optimize(split_max_areas=split_max_areas-1)
     pass
Example #10
0
def init_stuff():
    patches = {
        "flat_xy_square": (
            (0, 0, 0),
            (1 / 3.0, 0, 0),
            (2 / 3.0, 0, 0),
            (1, 0, 0),
            (0, 1 / 3.0, 0),
            (1 / 3.0, 1 / 3.0, 0),
            (2 / 3.0, 1 / 3.0, 0),
            (1, 1 / 3.0, 0),
            (0, 2 / 3.0, 0),
            (1 / 3.0, 2 / 3.0, 0),
            (2 / 3.0, 2 / 3.0, 0),
            (1, 2 / 3.0, 0),
            (0, 1, 0),
            (1 / 3.0, 1, 0),
            (2 / 3.0, 1, 0),
            (1, 1, 0),
        ),
        "bump_one": (
            (0, 0, 0),
            (0.1, 0, 0.1),
            (0.9, 0, 0.1),
            (1, 0, 0),
            (0, 0.1, 0.1),
            (0.1, 0.1, 0.1),
            (0.9, 0.1, 0.1),
            (1, 0.1, 0.1),
            (0, 0.9, 0.1),
            (0.1, 0.9, 0.1),
            (0.9, 0.9, 0.1),
            (1, 0.9, 0.1),
            (0, 1, 0),
            (0.1, 1, 0.1),
            (0.9, 1, 0.1),
            (1, 1, 0),
        ),
        "bump_two": (
            (0, 0, 0),
            (0.2, -0.2, 0.2),
            (0.8, -0.2, 0.2),
            (1, 0, 0),
            (-0.2, 0.2, 0.2),
            (0.2, 0.2, -0.1),
            (0.8, 0.2, -0.1),
            (1.2, 0.2, 0.2),
            (-0.2, 0.8, 0.2),
            (0.2, 0.8, -0.1),
            (0.8, 0.8, -0.1),
            (1.2, 0.8, 0.2),
            (0, 1, 0),
            (0.2, 1.2, 0.2),
            (0.8, 1.2, 0.2),
            (1, 1, 0),
        ),
    }
    patch = patches["flat_xy_square"]
    patch = patches["bump_two"]
    patch = patches["bump_two"]
    patch = patches["bump_one"]
    #patch = patches["flat_xy_square"]
    global opengl_surface
    import OpenGL.arrays.vbo as vbo
    import numpy
    from ctypes import sizeof, c_float, c_void_p, c_uint
    pts = []
    for coords in patch:
        pts.append(bezier.c_point(coords=coords))
    bp = bezier.c_bezier_patch(pts=pts)

    # data_array is an array of records, each of floats
    # Each record is:
    # 3 floats as a vertex
    # 3 floats as a normal
    float_size = sizeof(c_float)
    vertex_offset = c_void_p(0 * float_size)
    normal_offset = c_void_p(3 * float_size)
    record_len = 6 * float_size
    data_array = []
    n = 14
    for i in range(n + 1):
        for j in range(n + 1):
            data_array.append(
                bp.coord(i / (n + 0.0),
                         j / (n + 0.0)).get_coords(scale=(2.0, 2.0, 2.0),
                                                   offset=(-1., -1.0, .0)))
            data_array.append(
                bp.normal(i / (n + 0.0), j / (n + 0.0)).get_coords())
            pass
        pass

    # VBO is a vertex-buffer-object - really this is a VAO I believe
    vertices = vbo.VBO(data=numpy.array(data_array, dtype=numpy.float32))

    # target=GL_ELEMENT_ARRAY_BUFFER makes the VBO

    index_list = []
    if use_primitive_restart:
        glEnable(GL_PRIMITIVE_RESTART)
        pass
    for j in range(n):
        for i in range(n + 1):
            index_list.append(i + j * (n + 1))
            index_list.append(i + (j + 1) * (n + 1))
            pass
        if j < (n - 1):
            if use_primitive_restart:
                index_list.append(255)
                pass
            else:
                index_list.append((n) + (j + 1) * (n + 1))
                index_list.append((n) + (j + 1) * (n + 1))
                index_list.append((j + 1) * (n + 1))
                index_list.append((j + 1) * (n + 1))
                pass
        pass

    print index_list
    indices = vbo.VBO(data=numpy.array(index_list, dtype=numpy.uint8),
                      target=GL_ELEMENT_ARRAY_BUFFER)
    vertices.bind()
    indices.bind()
    opengl_surface["vertices"] = vertices
    opengl_surface["indices"] = indices
    opengl_surface["vertex_offset"] = vertex_offset
    opengl_surface["normal_offset"] = normal_offset
    opengl_surface["record_len"] = record_len
Example #11
0
def build_ship():
    skin_angles = { "jet":10.0, "bottom":70.0, "mid_b":65.0, "mid_m":85.0, "mid_t":115.0, "top":20.0 }
    bone_angles = { "base":60.0, "mid_b":80.0, "mid_m":80.0, "mid_t":80.0, "fin_t":80.0, "fin_b":40.0 }
    for b in bone_angles:
        import random
        bone_angles[b] += random.random()*5*0
    for s in skin_angles:
        import random
        skin_angles[b] += random.random()*5*0
    ship = bones.c_bone_group("ship")
    ship.add_child( bones.c_bone_var("anchor_point", "vector") )
    ship.add_child( bones.c_bone_var("direction", "vector") )
    ship.add_child( bones.c_bone_var("size", "scalar") )

    null_point = c_point((0.0,0.0))
    ship.set_node( "anchor_point", c_point((0.0,0.0)) )
    ship.set_node( "direction", c_point((0.0,1.0)) )
    ship.set_node( "size", 5.0 )

    bone_1 = bones.add_bezier_bone( ship, "bone1", num_pts=3, script = [ ("mult", ("get","size"), ("mult", 0.5, ("get","direction"))),
                                                                   ("dup"),
                                                                   ("set", "bone1.base_0", ("add", ("get","anchor_point"))), ("pop"),
                                                                   ("neg"),
                                                                   ("set", "bone1.base_2", ("add", ("get","anchor_point"))), ("pop"),
                                                                   ("set", "bone1.base_1", ("mult", 0.5, ("add", ("get", "bone1.base_0"), ("get", "bone1.base_2")))),
                                                                   ] )
    bone2 = bones.add_extend_bone( ship, "bone2", "bone1", scale=-0.95, rotation= 0.0, src=0.0 )
    bone3 = bones.add_extend_bone( ship, "bone3", "bone2", scale=0.5,  rotation= 0.0, src=1.0 )
    bone4 = bones.add_extend_bone( ship, "bone4", "bone1", scale=0.5,  rotation= 0.0, src=1.0 )
    bone5 = bones.add_extend_bone( ship, "bone5", "bone2", scale= 0.45, rotation= bone_angles["mid_t"], src=1.0 )
    bone6 = bones.add_extend_bone( ship, "bone6", "bone2", scale= 0.45, rotation=-bone_angles["mid_t"], src=1.0 )
    bone7 = bones.add_extend_bone( ship, "bone7", "bone1", scale=-0.8, rotation= bone_angles["mid_m"], src=0.0 )
    bone8 = bones.add_extend_bone( ship, "bone8", "bone1", scale=-0.8, rotation=-bone_angles["mid_m"], src=0.0 )
    bone9 = bones.add_extend_bone( ship, "bone9", "bone1", scale= 0.7, rotation=-bone_angles["mid_b"], src=1.0 )
    bone10 =bones.add_extend_bone( ship, "bone10","bone1", scale= 0.7, rotation= bone_angles["mid_b"], src=1.0 )
    bone11= bones.add_extend_bone( ship, "bone11","bone4", scale= 0.5, rotation=-bone_angles["base"], src=1.0 )
    bone12= bones.add_extend_bone( ship, "bone12","bone4", scale= 0.5, rotation= bone_angles["base"], src=1.0 )
    bone13= bones.add_bezier_bone( ship, "bone13", num_pts=4, script= bones.bezier4_script( ( ("bone9",1.0),
                                                                                             ("bone9",1.0,0.5,180-skin_angles["mid_b"]),
                                                                                             ("bone11",1.0,0.5,   -skin_angles["bottom"]),
                                                                                             ("bone11",1.0) ) ) )
    bone14= bones.add_extend_bone( ship, "bone14","bone13", scale=-0.6, rotation=bone_angles["fin_t"], src=0.2 )
    bone15= bones.add_extend_bone( ship, "bone15","bone14", scale=-0.8, rotation=bone_angles["fin_b"]-180.0, src=1.0 )
    bone16= bones.add_bezier_bone( ship, "bone16", num_pts=4, script= bones.bezier4_script( ( ("bone10",1.0),
                                                                                             ("bone10",1.0,0.5,  -180+skin_angles["mid_b"]),
                                                                                             ("bone12",1.0,0.5, skin_angles["bottom"]),
                                                                                             ("bone12",1.0) ) ) )
    bone17= bones.add_extend_bone( ship, "bone17","bone16", scale=-0.6, rotation=-bone_angles["fin_t"], src=0.2 )
    bone18= bones.add_extend_bone( ship, "bone18","bone17", scale=-0.8, rotation=180.0-bone_angles["fin_b"], src=1.0 )

    ship_plane = ship.add_child(bones.c_bone_plane("ship_plane"))
    ship_skin = ship_plane.add_child(bones.c_bone_drawable("ship_skin",fill=(255,150,120), stroke=(0,0,0) ))
    skin1 = bones.add_bezier_bone( ship_skin, "skin1", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone12",1.0),
                                                                                           ("bone12",1.0,0.4, 180+skin_angles["jet"]),
                                                                                           ("bone11",1.0,0.4, 180-skin_angles["jet"]),
                                                                                           ("bone11",1.0) ) ) )
    skin2 = bones.add_bezier_bone( ship_skin, "skin2", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone9",1.0),
                                                                                           ("bone9",1.0,0.5, 180-skin_angles["mid_b"]),
                                                                                           ("bone11",1.0,0.5, -skin_angles["bottom"]),
                                                                                           ("bone11",1.0) ) ) )
    skin3 = bones.add_bezier_bone( ship_skin, "skin3", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone10",1.0),
                                                                                           ("bone10",1.0,0.5, -180+skin_angles["mid_b"]),
                                                                                           ("bone12",1.0,0.5, skin_angles["bottom"]),
                                                                                           ("bone12",1.0) ) ) )
    skin4 = bones.add_bezier_bone( ship_skin, "skin4", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone9",1.0),
                                                                                           ("bone9",1.0,-0.5, 180-skin_angles["mid_b"]),
                                                                                           ("bone7",1.0,0.5, skin_angles["mid_m"]),
                                                                                           ("bone7",1.0) ) ) )
    skin5 = bones.add_bezier_bone( ship_skin, "skin5", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone10",1.0),
                                                                                           ("bone10",1.0,0.5, skin_angles["mid_b"]),
                                                                                           ("bone8",1.0,-0.5, 180-skin_angles["mid_m"]),
                                                                                           ("bone8",1.0) ) ) )
    skin6 = bones.add_bezier_bone( ship_skin, "skin6", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone7",1.0),
                                                                                           ("bone7",1.0,-0.5, skin_angles["mid_m"]),
                                                                                           ("bone5",1.0,0.5, 180-skin_angles["mid_t"]),
                                                                                           ("bone5",1.0) ) ) )
    skin7 = bones.add_bezier_bone( ship_skin, "skin7", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone8",1.0),
                                                                                           ("bone8",1.0, 0.5, 180-skin_angles["mid_m"]),
                                                                                           ("bone6",1.0,-0.5, skin_angles["mid_t"]),
                                                                                           ("bone6",1.0) ) ) )
    skin8 = bones.add_bezier_bone( ship_skin, "skin8", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone5",1.0),
                                                                                           ("bone5",1.0,-0.5, 180-skin_angles["mid_t"]),
                                                                                           ("bone3",1.0,0.3, 90+skin_angles["top"]),
                                                                                           ("bone3",1.0) ) ) )
    skin9 = bones.add_bezier_bone( ship_skin, "skin9", num_pts=4, scope=ship, script= bones.bezier4_script( ( ("bone6",1.0),
                                                                                           ("bone6",1.0,0.5, skin_angles["mid_t"]),
                                                                                           ("bone3",1.0,0.3, 270-skin_angles["top"]),
                                                                                           ("bone3",1.0) ) ) )
    ship_skin.add_child(bones.c_bone_ref("sk1", skin1, opts={"start":0.0,"end":1.0}))
    ship_skin.add_child(bones.c_bone_ref("sk2", skin2, opts={"start":1.0,"end":0.0}))
    ship_skin.add_child(bones.c_bone_ref("sk4", skin4, opts={"start":0.0,"end":1.0}))
    ship_skin.add_child(bones.c_bone_ref("sk6", skin6, opts={"start":0.0,"end":1.0}))
    ship_skin.add_child(bones.c_bone_ref("sk8", skin8, opts={"start":0.0,"end":1.0}))
    ship_skin.add_child(bones.c_bone_ref("sk9", skin9, opts={"start":1.0,"end":0.0}))
    ship_skin.add_child(bones.c_bone_ref("sk7", skin7, opts={"start":1.0,"end":0.0}))
    ship_skin.add_child(bones.c_bone_ref("sk5", skin5, opts={"start":1.0,"end":0.0}))
    ship_skin.add_child(bones.c_bone_ref("sk3", skin3, opts={"start":0.0,"end":1.0}))

    leg1_plane = ship.add_child(bones.c_bone_plane("leg1_plane",depth=10))
    leg1_skin = leg1_plane.add_child(bones.c_bone_drawable("leg1_skin",fill=(255,200,200), stroke=(0,0,0) ))
    leg1skin1 = bones.add_bezier_bone( leg1_skin, "leg1skin1", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin2",0.75),
                                                                                                      ("bone14",0.50,0.4, 90.0),
                                                                                                      ("bone15",0.30,0.4, 90.0),
                                                                                                      ("bone15",1.0) ) ) )
    leg1skin2 = bones.add_bezier_bone( leg1_skin, "leg1skin2", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin4",0.45),
                                                                                                      ("bone14",0.50,-0.4, 90.0),
                                                                                                      ("bone15",0.30,-0.4, 90.0),
                                                                                                      ("bone15",1.0) ) ) )
    leg1_skin.add_child(bones.c_bone_ref("ls1", leg1skin1, opts={"start":1.0,"end":0.0}))
    leg1_skin.add_child(bones.c_bone_ref("ls2", leg1skin2, opts={"start":0.0,"end":1.0}))

    leg2_plane = ship.add_child(bones.c_bone_plane("leg2_plane", depth=10))
    leg2_skin = leg2_plane.add_child(bones.c_bone_drawable("leg2_skin",fill=(255,200,200), stroke=(0,0,0) ))
    leg2skin1 = bones.add_bezier_bone( leg2_skin, "leg2skin1", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin3",0.75),
                                                                                                      ("bone17",0.50,-0.4, 90.0),
                                                                                                      ("bone18",0.30,-0.4, 90.0),
                                                                                                      ("bone18",1.0) ) ) )
    leg2skin2 = bones.add_bezier_bone( leg2_skin, "leg2skin2", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin5",0.45),
                                                                                                      ("bone17",0.50,0.4, 90.0),
                                                                                                      ("bone18",0.30,0.4, 90.0),
                                                                                                      ("bone18",1.0) ) ) )

    leg2_skin.add_child(bones.c_bone_ref("ls1", leg2skin1, opts={"start":1.0,"end":0.0}))
    leg2_skin.add_child(bones.c_bone_ref("ls2", leg2skin2, opts={"start":0.0,"end":1.0}))

    decring1 = bones.add_bezier_bone( ship_skin, "decring1", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin6",0.8),
                                                                                                      ("bone2",0.9),
                                                                                                      ("bone2",0.9),
                                                                                                      ("skin7",0.8) ) ) )

    decring2 = bones.add_bezier_bone( ship_skin, "decring2", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin6",0.0),
                                                                                                      ("bone2",0.05),
                                                                                                      ("bone2",0.05),
                                                                                                      ("skin7",0.0) ) ) )

    decwind0 = bones.add_bezier_bone( ship_skin, "decwind0", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("decring2",0.2,0.08,90.0),
                                                                                                   ("decring2",0.3,0.08,90.0),
                                                                                                   ("decring2",0.5,0.1,90.0),
                                                                                                   ("decring2",0.6,0.1,90.0) ) ) )

    decwind1 = bones.add_bezier_bone( ship_skin, "decwind1", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("decwind0",0.0),
                                                                                                   ("decwind0",0.0,1.17,90.0),
                                                                                                   ("decwind0",0.0,1.17,90.0),
                                                                                                   ("decwind0",0.5,1.0,90.0) ) ) )

    decwind2 = bones.add_bezier_bone( ship_skin, "decwind2", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("decwind0",1.0),
                                                                                                   ("decwind0",1.0,1.5,90.0),
                                                                                                   ("decwind0",1.0,1.5,90.0),
                                                                                                   ("decwind0",0.5,1.0,90.0) ) ) )

    decring3 = bones.add_bezier_bone( ship_skin, "decring3", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("skin4",0.3),
                                                                                                      ("bone1",0.9),
                                                                                                      ("bone1",0.9),
                                                                                                      ("skin5",0.3) ) ) )

    decdoor0 = bones.add_bezier_bone( ship_skin, "decdoor0", num_pts=4, scope=(ship_skin,ship), script= bones.bezier4_script( ( ("decring3",0.65),
                                                                                                   ("decring3",0.6,0.4,90),
                                                                                                   ("decring3",0.95,0.4,90),
                                                                                                   ("decring3",0.9) ) ) )

    decorations = ship.add_child(bones.c_bone_plane("decorations", depth=-10))
    decring1_d   = decorations.add_child(bones.c_bone_drawable("dec_ring1", stroke=(0,0,0) ))
    decring1_d.add_child(bones.c_bone_ref("r1", decring1, opts={"start":0.0,"end":1.0}))
    decring2_d   = decorations.add_child(bones.c_bone_drawable("dec_ring2", stroke=(0,0,0) ))
    decring2_d.add_child(bones.c_bone_ref("r2", decring2, opts={"start":0.0,"end":1.0}))
    decring3_d   = decorations.add_child(bones.c_bone_drawable("dec_ring3", stroke=(0,0,0) ))
    decring3_d.add_child(bones.c_bone_ref("r3", decring3, opts={"start":0.0,"end":1.0}))
    decwin_d   = decorations.add_child(bones.c_bone_drawable("dec_win", fill=(255,255,200),stroke=(0,0,0) ))
    decwin_d.add_child(bones.c_bone_ref("w0", decwind0, opts={"start":1.0,"end":0.0}))
    decwin_d.add_child(bones.c_bone_ref("w1", decwind1, opts={"start":0.0,"end":1.0}))
    decwin_d.add_child(bones.c_bone_ref("w2", decwind2, opts={"start":1.0,"end":0.0}))
    decdoor_d   = decorations.add_child(bones.c_bone_drawable("dec_door", stroke=(0,0,0) ))
    decdoor_d.add_child(bones.c_bone_ref("d0", decdoor0, opts={"start":1.0,"end":0.0}))

    return ship
Example #12
0
def build_ship():
    skin_angles = {
        "jet": 10.0,
        "bottom": 70.0,
        "mid_b": 65.0,
        "mid_m": 85.0,
        "mid_t": 115.0,
        "top": 20.0
    }
    bone_angles = {
        "base": 60.0,
        "mid_b": 80.0,
        "mid_m": 80.0,
        "mid_t": 80.0,
        "fin_t": 80.0,
        "fin_b": 40.0
    }
    for b in bone_angles:
        import random
        bone_angles[b] += random.random() * 5 * 0
    for s in skin_angles:
        import random
        skin_angles[b] += random.random() * 5 * 0
    ship = bones.c_bone_group("ship")
    ship.add_child(bones.c_bone_var("anchor_point", "vector"))
    ship.add_child(bones.c_bone_var("direction", "vector"))
    ship.add_child(bones.c_bone_var("size", "scalar"))

    null_point = c_point((0.0, 0.0))
    ship.set_node("anchor_point", c_point((0.0, 0.0)))
    ship.set_node("direction", c_point((0.0, 1.0)))
    ship.set_node("size", 5.0)

    bone_1 = bones.add_bezier_bone(
        ship,
        "bone1",
        num_pts=3,
        script=[
            ("mult", ("get", "size"), ("mult", 0.5, ("get", "direction"))),
            ("dup"),
            ("set", "bone1.base_0", ("add", ("get", "anchor_point"))),
            ("pop"),
            ("neg"),
            ("set", "bone1.base_2", ("add", ("get", "anchor_point"))),
            ("pop"),
            ("set", "bone1.base_1", ("mult", 0.5, ("add", ("get",
                                                           "bone1.base_0"),
                                                   ("get", "bone1.base_2")))),
        ])
    bone2 = bones.add_extend_bone(ship,
                                  "bone2",
                                  "bone1",
                                  scale=-0.95,
                                  rotation=0.0,
                                  src=0.0)
    bone3 = bones.add_extend_bone(ship,
                                  "bone3",
                                  "bone2",
                                  scale=0.5,
                                  rotation=0.0,
                                  src=1.0)
    bone4 = bones.add_extend_bone(ship,
                                  "bone4",
                                  "bone1",
                                  scale=0.5,
                                  rotation=0.0,
                                  src=1.0)
    bone5 = bones.add_extend_bone(ship,
                                  "bone5",
                                  "bone2",
                                  scale=0.45,
                                  rotation=bone_angles["mid_t"],
                                  src=1.0)
    bone6 = bones.add_extend_bone(ship,
                                  "bone6",
                                  "bone2",
                                  scale=0.45,
                                  rotation=-bone_angles["mid_t"],
                                  src=1.0)
    bone7 = bones.add_extend_bone(ship,
                                  "bone7",
                                  "bone1",
                                  scale=-0.8,
                                  rotation=bone_angles["mid_m"],
                                  src=0.0)
    bone8 = bones.add_extend_bone(ship,
                                  "bone8",
                                  "bone1",
                                  scale=-0.8,
                                  rotation=-bone_angles["mid_m"],
                                  src=0.0)
    bone9 = bones.add_extend_bone(ship,
                                  "bone9",
                                  "bone1",
                                  scale=0.7,
                                  rotation=-bone_angles["mid_b"],
                                  src=1.0)
    bone10 = bones.add_extend_bone(ship,
                                   "bone10",
                                   "bone1",
                                   scale=0.7,
                                   rotation=bone_angles["mid_b"],
                                   src=1.0)
    bone11 = bones.add_extend_bone(ship,
                                   "bone11",
                                   "bone4",
                                   scale=0.5,
                                   rotation=-bone_angles["base"],
                                   src=1.0)
    bone12 = bones.add_extend_bone(ship,
                                   "bone12",
                                   "bone4",
                                   scale=0.5,
                                   rotation=bone_angles["base"],
                                   src=1.0)
    bone13 = bones.add_bezier_bone(
        ship,
        "bone13",
        num_pts=4,
        script=bones.bezier4_script(
            (("bone9", 1.0), ("bone9", 1.0, 0.5, 180 - skin_angles["mid_b"]),
             ("bone11", 1.0, 0.5, -skin_angles["bottom"]), ("bone11", 1.0))))
    bone14 = bones.add_extend_bone(ship,
                                   "bone14",
                                   "bone13",
                                   scale=-0.6,
                                   rotation=bone_angles["fin_t"],
                                   src=0.2)
    bone15 = bones.add_extend_bone(ship,
                                   "bone15",
                                   "bone14",
                                   scale=-0.8,
                                   rotation=bone_angles["fin_b"] - 180.0,
                                   src=1.0)
    bone16 = bones.add_bezier_bone(
        ship,
        "bone16",
        num_pts=4,
        script=bones.bezier4_script(
            (("bone10", 1.0), ("bone10", 1.0, 0.5,
                               -180 + skin_angles["mid_b"]),
             ("bone12", 1.0, 0.5, skin_angles["bottom"]), ("bone12", 1.0))))
    bone17 = bones.add_extend_bone(ship,
                                   "bone17",
                                   "bone16",
                                   scale=-0.6,
                                   rotation=-bone_angles["fin_t"],
                                   src=0.2)
    bone18 = bones.add_extend_bone(ship,
                                   "bone18",
                                   "bone17",
                                   scale=-0.8,
                                   rotation=180.0 - bone_angles["fin_b"],
                                   src=1.0)

    ship_plane = ship.add_child(bones.c_bone_plane("ship_plane"))
    ship_skin = ship_plane.add_child(
        bones.c_bone_drawable("ship_skin",
                              fill=(255, 150, 120),
                              stroke=(0, 0, 0)))
    skin1 = bones.add_bezier_bone(
        ship_skin,
        "skin1",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone12", 1.0), ("bone12", 1.0, 0.4, 180 + skin_angles["jet"]),
             ("bone11", 1.0, 0.4, 180 - skin_angles["jet"]), ("bone11", 1.0))))
    skin2 = bones.add_bezier_bone(
        ship_skin,
        "skin2",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone9", 1.0), ("bone9", 1.0, 0.5, 180 - skin_angles["mid_b"]),
             ("bone11", 1.0, 0.5, -skin_angles["bottom"]), ("bone11", 1.0))))
    skin3 = bones.add_bezier_bone(
        ship_skin,
        "skin3",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone10", 1.0), ("bone10", 1.0, 0.5,
                               -180 + skin_angles["mid_b"]),
             ("bone12", 1.0, 0.5, skin_angles["bottom"]), ("bone12", 1.0))))
    skin4 = bones.add_bezier_bone(
        ship_skin,
        "skin4",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone9", 1.0), ("bone9", 1.0, -0.5, 180 - skin_angles["mid_b"]),
             ("bone7", 1.0, 0.5, skin_angles["mid_m"]), ("bone7", 1.0))))
    skin5 = bones.add_bezier_bone(ship_skin,
                                  "skin5",
                                  num_pts=4,
                                  scope=ship,
                                  script=bones.bezier4_script(
                                      (("bone10", 1.0), ("bone10", 1.0, 0.5,
                                                         skin_angles["mid_b"]),
                                       ("bone8", 1.0, -0.5,
                                        180 - skin_angles["mid_m"]), ("bone8",
                                                                      1.0))))
    skin6 = bones.add_bezier_bone(
        ship_skin,
        "skin6",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone7", 1.0), ("bone7", 1.0, -0.5, skin_angles["mid_m"]),
             ("bone5", 1.0, 0.5, 180 - skin_angles["mid_t"]), ("bone5", 1.0))))
    skin7 = bones.add_bezier_bone(
        ship_skin,
        "skin7",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone8", 1.0), ("bone8", 1.0, 0.5, 180 - skin_angles["mid_m"]),
             ("bone6", 1.0, -0.5, skin_angles["mid_t"]), ("bone6", 1.0))))
    skin8 = bones.add_bezier_bone(
        ship_skin,
        "skin8",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone5", 1.0), ("bone5", 1.0, -0.5, 180 - skin_angles["mid_t"]),
             ("bone3", 1.0, 0.3, 90 + skin_angles["top"]), ("bone3", 1.0))))
    skin9 = bones.add_bezier_bone(
        ship_skin,
        "skin9",
        num_pts=4,
        scope=ship,
        script=bones.bezier4_script(
            (("bone6", 1.0), ("bone6", 1.0, 0.5, skin_angles["mid_t"]),
             ("bone3", 1.0, 0.3, 270 - skin_angles["top"]), ("bone3", 1.0))))
    ship_skin.add_child(
        bones.c_bone_ref("sk1", skin1, opts={
            "start": 0.0,
            "end": 1.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk2", skin2, opts={
            "start": 1.0,
            "end": 0.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk4", skin4, opts={
            "start": 0.0,
            "end": 1.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk6", skin6, opts={
            "start": 0.0,
            "end": 1.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk8", skin8, opts={
            "start": 0.0,
            "end": 1.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk9", skin9, opts={
            "start": 1.0,
            "end": 0.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk7", skin7, opts={
            "start": 1.0,
            "end": 0.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk5", skin5, opts={
            "start": 1.0,
            "end": 0.0
        }))
    ship_skin.add_child(
        bones.c_bone_ref("sk3", skin3, opts={
            "start": 0.0,
            "end": 1.0
        }))

    leg1_plane = ship.add_child(bones.c_bone_plane("leg1_plane", depth=10))
    leg1_skin = leg1_plane.add_child(
        bones.c_bone_drawable("leg1_skin",
                              fill=(255, 200, 200),
                              stroke=(0, 0, 0)))
    leg1skin1 = bones.add_bezier_bone(leg1_skin,
                                      "leg1skin1",
                                      num_pts=4,
                                      scope=(ship_skin, ship),
                                      script=bones.bezier4_script(
                                          (("skin2", 0.75), ("bone14", 0.50,
                                                             0.4, 90.0),
                                           ("bone15", 0.30, 0.4,
                                            90.0), ("bone15", 1.0))))
    leg1skin2 = bones.add_bezier_bone(leg1_skin,
                                      "leg1skin2",
                                      num_pts=4,
                                      scope=(ship_skin, ship),
                                      script=bones.bezier4_script(
                                          (("skin4", 0.45), ("bone14", 0.50,
                                                             -0.4, 90.0),
                                           ("bone15", 0.30, -0.4,
                                            90.0), ("bone15", 1.0))))
    leg1_skin.add_child(
        bones.c_bone_ref("ls1", leg1skin1, opts={
            "start": 1.0,
            "end": 0.0
        }))
    leg1_skin.add_child(
        bones.c_bone_ref("ls2", leg1skin2, opts={
            "start": 0.0,
            "end": 1.0
        }))

    leg2_plane = ship.add_child(bones.c_bone_plane("leg2_plane", depth=10))
    leg2_skin = leg2_plane.add_child(
        bones.c_bone_drawable("leg2_skin",
                              fill=(255, 200, 200),
                              stroke=(0, 0, 0)))
    leg2skin1 = bones.add_bezier_bone(leg2_skin,
                                      "leg2skin1",
                                      num_pts=4,
                                      scope=(ship_skin, ship),
                                      script=bones.bezier4_script(
                                          (("skin3", 0.75), ("bone17", 0.50,
                                                             -0.4, 90.0),
                                           ("bone18", 0.30, -0.4,
                                            90.0), ("bone18", 1.0))))
    leg2skin2 = bones.add_bezier_bone(leg2_skin,
                                      "leg2skin2",
                                      num_pts=4,
                                      scope=(ship_skin, ship),
                                      script=bones.bezier4_script(
                                          (("skin5", 0.45), ("bone17", 0.50,
                                                             0.4, 90.0),
                                           ("bone18", 0.30, 0.4,
                                            90.0), ("bone18", 1.0))))

    leg2_skin.add_child(
        bones.c_bone_ref("ls1", leg2skin1, opts={
            "start": 1.0,
            "end": 0.0
        }))
    leg2_skin.add_child(
        bones.c_bone_ref("ls2", leg2skin2, opts={
            "start": 0.0,
            "end": 1.0
        }))

    decring1 = bones.add_bezier_bone(ship_skin,
                                     "decring1",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("skin6", 0.8), ("bone2", 0.9),
                                          ("bone2", 0.9), ("skin7", 0.8))))

    decring2 = bones.add_bezier_bone(ship_skin,
                                     "decring2",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("skin6", 0.0), ("bone2", 0.05),
                                          ("bone2", 0.05), ("skin7", 0.0))))

    decwind0 = bones.add_bezier_bone(ship_skin,
                                     "decwind0",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("decring2", 0.2, 0.08, 90.0),
                                          ("decring2", 0.3, 0.08,
                                           90.0), ("decring2", 0.5, 0.1, 90.0),
                                          ("decring2", 0.6, 0.1, 90.0))))

    decwind1 = bones.add_bezier_bone(ship_skin,
                                     "decwind1",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("decwind0", 0.0), ("decwind0", 0.0,
                                                              1.17, 90.0),
                                          ("decwind0", 0.0, 1.17, 90.0),
                                          ("decwind0", 0.5, 1.0, 90.0))))

    decwind2 = bones.add_bezier_bone(ship_skin,
                                     "decwind2",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("decwind0", 1.0), ("decwind0", 1.0,
                                                              1.5, 90.0),
                                          ("decwind0", 1.0, 1.5, 90.0),
                                          ("decwind0", 0.5, 1.0, 90.0))))

    decring3 = bones.add_bezier_bone(ship_skin,
                                     "decring3",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("skin4", 0.3), ("bone1", 0.9),
                                          ("bone1", 0.9), ("skin5", 0.3))))

    decdoor0 = bones.add_bezier_bone(ship_skin,
                                     "decdoor0",
                                     num_pts=4,
                                     scope=(ship_skin, ship),
                                     script=bones.bezier4_script(
                                         (("decring3", 0.65), ("decring3", 0.6,
                                                               0.4, 90),
                                          ("decring3", 0.95, 0.4,
                                           90), ("decring3", 0.9))))

    decorations = ship.add_child(bones.c_bone_plane("decorations", depth=-10))
    decring1_d = decorations.add_child(
        bones.c_bone_drawable("dec_ring1", stroke=(0, 0, 0)))
    decring1_d.add_child(
        bones.c_bone_ref("r1", decring1, opts={
            "start": 0.0,
            "end": 1.0
        }))
    decring2_d = decorations.add_child(
        bones.c_bone_drawable("dec_ring2", stroke=(0, 0, 0)))
    decring2_d.add_child(
        bones.c_bone_ref("r2", decring2, opts={
            "start": 0.0,
            "end": 1.0
        }))
    decring3_d = decorations.add_child(
        bones.c_bone_drawable("dec_ring3", stroke=(0, 0, 0)))
    decring3_d.add_child(
        bones.c_bone_ref("r3", decring3, opts={
            "start": 0.0,
            "end": 1.0
        }))
    decwin_d = decorations.add_child(
        bones.c_bone_drawable("dec_win",
                              fill=(255, 255, 200),
                              stroke=(0, 0, 0)))
    decwin_d.add_child(
        bones.c_bone_ref("w0", decwind0, opts={
            "start": 1.0,
            "end": 0.0
        }))
    decwin_d.add_child(
        bones.c_bone_ref("w1", decwind1, opts={
            "start": 0.0,
            "end": 1.0
        }))
    decwin_d.add_child(
        bones.c_bone_ref("w2", decwind2, opts={
            "start": 1.0,
            "end": 0.0
        }))
    decdoor_d = decorations.add_child(
        bones.c_bone_drawable("dec_door", stroke=(0, 0, 0)))
    decdoor_d.add_child(
        bones.c_bone_ref("d0", decdoor0, opts={
            "start": 1.0,
            "end": 0.0
        }))

    return ship