예제 #1
0
def pedestal(obj=None, d=1.0):
    """
    A pedestal with an optional object on top.
    Sits centered on its base.
    """

    pedestal = ddd.cube(d=d / 2.0).material(ddd.mats.bronze)
    pedestal = ddd.uv.map_cubic(pedestal)

    obj = obj.translate([0, 0, d])

    item = ddd.group([pedestal, obj], name="Pedestal: %s" % obj.name)
    return item
예제 #2
0
파일: mapillary.py 프로젝트: jjmontesl/ddd
def osm_extras_mapillary_get(pipeline, osm, root, logger):

    # Add mapillary items
    # TODO: Move to separate task and rule module, separate point generation from image/metadata generation, reuse code, this could be much shorter
    mc = MapillaryClient(client_id=pipeline.data['mapillary:client_id'])
    transformer = pyproj.Transformer.from_proj(osm.osm_proj, osm.ddd_proj)
    transformer2 = pyproj.Transformer.from_proj(osm.ddd_proj, osm.osm_proj)
    query_coords = osm.area_crop2.centroid().geom.coords[0]
    query_coords = project_coordinates(query_coords, transformer2)

    query_limit = 200
    query_radius = 500
    logger.info("Requesting Mapillary images near to (limit=%d, radius=%d)",
                query_coords, query_limit, query_radius)
    data = mc.images_list(query_coords, limit=query_limit, radius=query_radius)
    for feature in data['features'][:]:

        key = feature['properties']['key']
        pano = feature['properties']['pano']
        camera_angle = feature['properties']['ca']
        geom = feature['geometry']
        coords = geom['coordinates']
        #coords = (float(coords[0]) * 111000.0, float(coords[1]) * 111000.0)

        coords = project_coordinates(coords, transformer)
        logger.debug(
            "Mapillary Image: %s  CameraAngle: %.1f  Pano: %s  Coords: %s" %
            (key, camera_angle, pano, coords))

        mc.request_image(key)
        image = mc.image_textured(feature).scale([3, 3, 3])
        image_height = 1.5
        image = image.translate([0, 1, 0])
        image = image.rotate([0, 0, (0 + (-camera_angle)) * ddd.DEG_TO_RAD])
        image = image.translate([coords[0], coords[1], image_height])

        cam = ddd.cube(d=0.05).translate([coords[0], coords[1], image_height
                                          ]).material(ddd.mats.highlight)
        image.append(cam)

        image = terrain.terrain_geotiff_min_elevation_apply(
            image, osm.ddd_proj)

        osm.other_3d.append(image)

    logger.info("Added %d images from Mapillary.", len(osm.other_3d.children))

    # Optinally save Mapillary data only
    if osm.other_3d.children:
        osm.other_3d.save("/tmp/mapi.glb")
예제 #3
0
def fountain(r=1.5):
    # Base
    base = ddd.disc(r=r, resolution=2).extrude(0.30).material(ddd.mats.stone)
    base = ddd.uv.map_cylindrical(base)

    # Fountain
    fountain = ddd.sphere(r=r, subdivisions=1).subtract(ddd.cube(d=r * 1.2)).subtract(ddd.sphere(r=r - 0.2, subdivisions=1))
    fountain = fountain.translate([0, 0, 1.2])  # TODO: align
    fountain = fountain.material(ddd.mats.stone)
    fountain = ddd.uv.map_spherical(fountain)
    #.subtract(base)
    # Water
    water = ddd.disc(r=r-0.2, resolution=2).triangulate().translate([0, 0, 1.1]).material(ddd.mats.water)
    water.extra['ddd:collider'] = False
    water.extra['ddd:occluder'] = False
    water.extra['ddd:shadows'] = False

    item = ddd.group([base, fountain, water])
    return item
예제 #4
0
def pipeline_start(pipeline, root):
    """
    Tests subdivision on several geometries (check wireframe).
    """

    items = ddd.group3()

    # Subdivision to grid
    fig1 = ddd.rect([-4, -2, 4, 2])
    fig2 = ddd.rect([-3, -1, -1, 1])
    figh = fig1.subtract(fig2)
    fig = figh.extrude_step(figh,
                            1.0,
                            base=False,
                            method=ddd.EXTRUSION_METHOD_SUBTRACT)
    fig = fig.extrude_step(figh.buffer(-0.25),
                           1.0,
                           method=ddd.EXTRUSION_METHOD_SUBTRACT)
    fig = fig.material(ddd.mats.logo)
    fig = ddd.uv.map_cubic(fig)
    fig = ddd.meshops.subdivide_to_grid(fig, 0.5)
    fig.show()
    items.append(fig)

    # Test slicing with plane
    figa = ddd.meshops.slice_plane(fig, [-1, -1, -1], [0.3, 0.3, 0.3])
    #figa = ddd.uv.map_cubic(figa)  # This should not be needed, slice_plane should do this
    figb = ddd.meshops.slice_plane(fig, [1, 1, 1],
                                   [0.3, 0.3, 0.3]).material(ddd.MAT_HIGHLIGHT)
    ddd.group([figa, figb]).show()

    # Subdivide to grid
    coords = [[10, 10], [5, 9], [3, 12], [1, 5], [-8, 0], [10, 0]]
    ref = ddd.polygon(coords).subtract(ddd.rect([1, 1, 2, 2]))
    obj = ref.triangulate()
    obj = ddd.meshops.subdivide_to_grid(obj, 2.0)
    #obj= obj.subdivide_to_size(2.0)
    #ddd.group3([obj, ref.triangulate().material(ddd.MAT_HIGHLIGHT).translate([0, 0, -1])]).show()
    items.append(obj.scale([0.1, 0.1, 1]).translate([0, 0, 1]))

    # Subdivide to grid (cube)
    obj = ddd.cube(d=2)
    obj = obj.material(ddd.mats.dirt)
    obj = ddd.uv.map_cubic(obj)
    obj = ddd.meshops.subdivide_to_grid(obj, 0.5)
    #obj.show()
    items.append(obj)

    # Subdivide
    fig1 = ddd.rect().extrude(1)
    fig1 = fig1.subdivide_to_size(0.5)
    items.append(fig1)
    #fig1.show()

    fig1 = ddd.rect([1, 3]).extrude(1)
    fig1 = fig1.subdivide_to_size(0.5)
    items.append(fig1)

    # Pointy end
    fig = ddd.point().buffer(0.5, cap_style=ddd.CAP_ROUND)
    fig = fig.extrude_step(ddd.point(), 2)
    fig = fig.subdivide_to_size(0.5)
    items.append(fig)

    # Remove bottom test
    fig = ddd.cube(d=2)
    fig = fig.subdivide_to_size(1.0)
    fig = ddd.meshops.remove_faces_pointing(fig, ddd.VECTOR_DOWN)
    items.append(fig)

    # All items
    items = ddd.align.grid(items, space=10.0)
    items.append(ddd.helper.all())
    items.show()

    root.append(items)
예제 #5
0
    camera_angle = feature['properties']['ca']
    geom = feature['geometry']
    coords = geom['coordinates']
    coords = (float(coords[0]) * 111000.0, float(coords[1]) * 111000.0)

    print("Image: %s  CameraAngle: %s  Pano: %s  Coords: %s" % (key, camera_angle, pano, coords))


    mc.request_image(key)
    image = mc.image_textured(feature)
    image_height = 1.5
    image = image.translate([0, 1, 0])
    image = image.rotate([0, 0, (-camera_angle + 180) * ddd.DEG_TO_RAD])
    image = image.translate([coords[0], coords[1], image_height])

    cam = ddd.cube(d=0.1).translate([coords[0], coords[1], image_height]).material(ddd.mats.highlight)

    obj = ddd.group([image, cam], name="Image")

    items.append(obj)



#item.show()

#items = ddd.align.grid(items)
items = items.recenter(onplane=True)
items.append(ddd.helper.all())
items.save("/tmp/test.json")
items.save("/tmp/test.glb")
items.show()
예제 #6
0
파일: subdivide.py 프로젝트: c3ypt1c/ddd
from trimesh.grouping import merge_vertices

items = ddd.group3()

# Subdivide
fig1 = ddd.rect().extrude(1)
fig1 = fig1.subdivide_to_size(0.5)
items.append(fig1)
#fig1.show()

fig1 = ddd.rect([1, 3]).extrude(1)
fig1 = fig1.subdivide_to_size(0.5)
items.append(fig1)

# Pointy end
fig = ddd.point().buffer(0.5, cap_style=ddd.CAP_ROUND)
fig = fig.extrude_step(ddd.point(), 2)
fig = fig.subdivide_to_size(0.5)
items.append(fig)

# Remove bottom test
fig = ddd.cube(d=2)
fig = fig.subdivide_to_size(1.0)
fig = ddd.meshops.remove_faces_pointing(fig, ddd.VECTOR_DOWN)
items.append(fig)

# All items
items = ddd.align.grid(items, space=10.0)
items.append(ddd.helper.all())
items.show()