Exemplo n.º 1
0
def pipeline_start(pipeline, root):
    """
    Draws several catenary cables.
    """

    ddd.mats.traffic_signs = ddd.material(name="TrafficSigns", color="#ffffff", #color="#e01010",
                                      texture_path=ddd.DATA_DIR  + "/materials/traffic-signs-es/traffic_signs_es_0.png",
                                      atlas_path=ddd.DATA_DIR  + "/materials/traffic-signs-es/traffic_signs_es_0.plist",
                                      extra={'ddd:texture:resize': 2048})


    items = ddd.group3()

    # Cube with logo
    fig = ddd.box()
    fig = fig.material(ddd.mats.logo)
    fig = ddd.uv.map_cubic(fig)
    items.append(fig)

    # Sphere with logo
    fig = ddd.sphere()
    fig = fig.material(ddd.mats.logo)
    #fig = fig.merge_vertices()
    #fig = fig.smooth(math.pi*2)
    fig = ddd.uv.map_spherical(fig)
    fig = fig.translate([0, 0, 2])
    items.append(fig)

    # Cube
    fig = ddd.box()
    fig = fig.material(ddd.mats.traffic_signs)
    fig = ddd.uv.map_cubic(fig)
    #fig.show()
    #items.append(fig)

    fig = TextureAtlasUtils().create_sprite_rect(ddd.mats.traffic_signs)
    #fig.show()
    #items.append(fig)

    fig = TextureAtlasUtils().create_sprite_from_atlas(ddd.mats.traffic_signs, "ES_P6.png")
    #fig.show()
    #items.append(fig)


    '''
    ddd.mats.roadmarks = ddd.material(name="Roadmarks", color='#e8e8e8',
                                 texture_path=ddd.DATA_DIR + "/materials/road-marks-es/TexturesCom_Atlas_RoadMarkings2_White_1K_albedo_with_alpha.png",
                                 atlas_path=ddd.DATA_DIR  + "/materials/road-marks-es/RoadMarkings2.plist")

    fig = TextureAtlasUtils().create_sprite_from_atlas(ddd.mats.roadmarks, "give_way")
    fig.show()
    '''

    items = ddd.align.grid(items, width=4)
    items.append(ddd.helper.all(size=40.0, center=[5, 5, 0]).twosided())

    root.append(items)
Exemplo n.º 2
0
def floor_decoration_objects_fore(root, pipeline, obj):

    sprites_obj_floor = [
        ddd.mats.obj_bush_def,
        ddd.mats.obj_bush_wide,
        ddd.mats.obj_tree1,
        ddd.mats.obj_tree2,
        ddd.mats.obj_tree3,
        ddd.mats.obj_tree4,  # ddd.mats.obj_tree_intro,
        ddd.mats.obj_barsx4,
        ddd.mats.obj_plant,
        ddd.mats.obj_grid_panel,
        ddd.mats.obj_grid_panel_broken,
        ddd.mats.obj_plantsx1,
        ddd.mats.obj_plantsx3,
        ddd.mats.obj_flowerpot,
        ddd.mats.obj_flowers1,
        ddd.mats.obj_flowers2,
        # ddd.mats.obj_mailbox, ddd.mats.obj_bin, ddd.mats.obj_bench,
    ]

    line = obj.extra['floor_line']
    l = line.geom.length

    for d in (random.uniform(0.0, 1.0) *
              l, ):  # random.uniform(0.0, 1.0) * l):
        p, segment_idx, segment_coords_a, segment_coords_b = line.interpolate_segment(
            d)

        pos = [p[0], p[1] - 20.0]
        rndscale = random.uniform(0.8, 1.3)

        itempos = ddd.point(pos, "Floor Deco Object Fore")
        itempos = ddd.snap.project(itempos, line, +16.0 * rndscale)

        materials_floor = sprites_obj_floor
        material = random.choice(materials_floor)

        item = TextureAtlasUtils().create_sprite_rect(material)
        item = item.material(material)

        # TODO: Scale to sprite dimensions
        # item = item.scale([32.0, -32.0])
        rndscale = rndscale * material.extra.get("godot:obj:scale", 1.0)
        item.extra['godot:scale'] = [rndscale, rndscale]
        item = item.scale([rndscale, rndscale])

        item = ddd.align.anchor(item, [0.0, 0.5])

        item = item.translate(itempos.centroid())
        item.extra['ddd:angle'] = itempos.extra['ddd:angle'] - math.pi / 2.0
        item.extra['ddd:z_index'] = 39  #  39  # 45
        item.extra['godot:self_modulate'] = [
            0.45 * 255, 0.4 * 255, 0.4 * 255, 255
        ]
        item.extra['godot:light_mask'] = 0
        root.find("/Rooms/").append(item)
Exemplo n.º 3
0
def ceiling_decoration_objects_fore(root, pipeline, obj):

    sprites_obj_ceiling = [  # ddd.mats.obj_pipes,
        ddd.mats.obj_vines1, ddd.mats.obj_vines2, ddd.mats.obj_vines_h1,
        ddd.mats.obj_vines_h2, ddd.mats.obj_cables_h, ddd.mats.obj_cables2,
        ddd.mats.obj_beam1, ddd.mats.obj_beam2
    ]

    line = obj.extra['ceiling_line']
    l = line.length()

    min_length = 50
    if l < min_length: return

    positions = [
        random.uniform(0.0, 1.0) * l for _ in range(1 + int(l / 200.0))
    ]
    for d in positions:
        p, segment_idx, segment_coords_a, segment_coords_b = line.interpolate_segment(
            d)

        pos = [p[0], p[1] - 20.0]
        rndscale = random.uniform(0.8, 1.3)

        itempos = ddd.point(pos, "Ceiling Deco Object")
        itempos = ddd.snap.project(itempos, line, 0.0 * rndscale)

        materials_ceiling = sprites_obj_ceiling
        material = random.choice(materials_ceiling)

        item = TextureAtlasUtils().create_sprite_rect(material)
        item.name = "Ceiling Deco Object Fore: %s" % material.name
        item = item.material(material)

        # TODO: Scale to sprite dimensions
        # item = item.scale([32.0, -32.0])
        item.extra['godot:scale'] = [rndscale, rndscale]
        item = item.scale([rndscale, rndscale])

        item = ddd.align.anchor(item, [0.5, -0.5])

        item = item.translate(itempos.centroid())
        # item.extra['ddd:angle'] = itempos.extra['ddd:angle'] - math.pi / 2.0
        item.extra['ddd:z_index'] = 39  #  39  # 45
        item.extra['godot:self_modulate'] = [
            0.35 * 255, 0.3 * 255, 0.3 * 255, 255
        ]
        item.extra['godot:light_mask'] = 0

        root.find("/Rooms/").append(item)
Exemplo n.º 4
0
def room_decoration(root, pipeline, obj):

    obj = pipeline.data['rooms:background_union']

    points = obj.random_points(50)
    for p in points:
        pos = [p[0], p[1]]
        sprite_key = random.choice(sprites_bg + sprites_solid + sprites_bg_rc +
                                   sprites_solid_rc)
        item = TextureAtlasUtils().create_sprite_from_atlas(
            ddd.mats.spritesheet, sprite_key + ".png")
        # item.extra['godot:instance'] = "res://scenes/items/ItemGeneric.tscn"
        item = item.material(ddd.mats.spritesheet)

        # TODO: Scale to sprite dimensions
        item = item.scale([64.0, 64.0])

        rndscale = random.uniform(0.7, 3)
        item.extra['godot:scale'] = [rndscale, rndscale]
        item = item.scale([rndscale, rndscale])

        item = item.translate(pos)
        item.extra['ddd:z_index'] = -2

        root.find("/Rooms/").append(item)
Exemplo n.º 5
0
def ceiling_decoration_objects_aligned(root, pipeline, obj):

    sprites_obj_ceiling = [  # ddd.mats.obj_pipes,
        ddd.mats.obj_lamp_fluor,
    ]

    line = obj.extra['ceiling_line']
    l = line.length()

    min_length = 50
    if l < min_length: return

    for d in (random.uniform(0.0, 1.0) * l, ):
        p, segment_idx, segment_coords_a, segment_coords_b = line.interpolate_segment(
            d)

        pos = [p[0], p[1] - 20.0]
        rndscale = random.uniform(0.8, 1.3)

        itempos = ddd.point(pos, "Ceiling Deco Object")
        itempos = ddd.snap.project(itempos, line, 0.0 * rndscale)

        materials_ceiling = sprites_obj_ceiling
        material = random.choice(materials_ceiling)

        item = TextureAtlasUtils().create_sprite_rect(material)
        item.name = "Ceiling Deco Object: %s" % material.name
        item = item.material(material)

        # TODO: Scale to sprite dimensions
        # item = item.scale([32.0, -32.0])
        item.extra['godot:scale'] = [rndscale, rndscale]
        item = item.scale([rndscale, rndscale])

        item = ddd.align.anchor(item, [0.5, -0.5])

        item = item.translate(itempos.centroid())
        item.extra['ddd:angle'] = itempos.extra['ddd:angle'] - math.pi / 2.0
        item.extra['ddd:z_index'] = -2

        root.find("/Rooms/").append(item)
Exemplo n.º 6
0
def floor_decoration_items(root, pipeline, obj):

    line = obj.extra['floor_line']
    l = line.geom.length

    for d in (
            random.uniform(0.0, 1.0) * l,
            random.uniform(0.0, 1.0) * l,
            random.uniform(0.0, 1.0) * l,
    ):
        p, segment_idx, segment_coords_a, segment_coords_b = line.interpolate_segment(
            d)

        pos = [p[0], p[1] - 20.0]
        rndscale = random.uniform(0.8, 1.3)

        itempos = ddd.point(pos, "Floor Deco")
        itempos = ddd.snap.project(itempos, line, -16.0 * rndscale)

        sprites_floor = sprites_flags + sprites_plants + sprites_signs
        sprite_key = random.choice(sprites_floor)

        item = TextureAtlasUtils().create_sprite_from_atlas(
            ddd.mats.spritesheet, sprite_key + ".png")
        item = item.material(ddd.mats.spritesheet)

        # TODO: Scale to sprite dimensions
        item = item.scale([32.0, -32.0])

        item.extra['godot:scale'] = [rndscale, rndscale]
        item = item.scale([rndscale, rndscale])

        item = item.translate(itempos.centroid())
        item.extra['ddd:angle'] = itempos.extra['ddd:angle'] - math.pi / 2.0
        item.extra['ddd:z_index'] = -2

        root.find("/Rooms/").append(item)
Exemplo n.º 7
0
def ceiling_decoration_items(root, pipeline, obj):

    line = obj.extra['ceiling_line']
    l = line.geom.length

    positions = [
        random.uniform(0.0, 1.0) * l for _ in range(1 + int(l / 200.0))
    ]
    for d in positions:
        p, segment_idx, segment_coords_a, segment_coords_b = line.interpolate_segment(
            d)

        pos = [p[0], p[1] - 20.0]
        rndscale = random.uniform(1.0, 2.5)

        itempos = ddd.point(pos, "Ceiling Deco")
        itempos = ddd.snap.project(itempos, line, 16.0 * rndscale)

        sprites_ceiling = sprites_flags + sprites_plants + sprites_vine + sprites_vine
        sprite_key = random.choice(sprites_ceiling)

        item = TextureAtlasUtils().create_sprite_from_atlas(
            ddd.mats.spritesheet, sprite_key + ".png")
        item = item.material(ddd.mats.spritesheet)

        # TODO: Scale to sprite dimensions
        item = item.scale([32.0, -32.0])

        item.extra['godot:scale'] = [1.0, rndscale]
        item = item.scale([rndscale, rndscale])

        item = item.translate(itempos.centroid())
        item.extra['ddd:angle'] = itempos.extra['ddd:angle'] + math.pi / 2.0
        item.extra['ddd:z_index'] = -2

        root.find("/Rooms/").append(item)
Exemplo n.º 8
0
def road_marking(marktype, size=2.0, enlarge=1.4):
    mark = TextureAtlasUtils().create_sprite_from_atlas(ddd.mats.roadmarks, marktype)
    mark = mark.triangulate()
    mark = mark.scale([size, size * enlarge, 1.0])
    return mark