Ejemplo n.º 1
0
    def __init__(self, world, autopilot):
        self.world = world
        self.autopilot = autopilot

        blueprint_library = self.world.get_blueprint_library()

        self.vehicle = None

        i = 0
        while True:
            try:
                self.vehicle = world.spawn_actor(
                    # blueprint_library.find('vehicle.tesla.model3'),
                    blueprint_library.find('vehicle.ford.mustang'),
                    self.world.get_map().get_spawn_points()[i])
                break
            except RuntimeError:
                i += 1

        self.vehicle.set_simulate_physics(True)

        left_transform = carla.Transform(
            carla.Location(x=2.25, y=-0.15, z=0.9), carla.Rotation(pitch=-0))
        right_transform = carla.Transform(
            carla.Location(x=2.25, y=+0.15, z=0.9), carla.Rotation(pitch=-0))
        size = (1024, 720)
        fov = 45

        self.sensors = {
            'left':
            create_camera(self.vehicle, size, fov, left_transform),
            'right':
            create_camera(self.vehicle, size, fov, right_transform),
            'semantic':
            create_camera(self.vehicle, size, fov, left_transform,
                          'sensor.camera.semantic_segmentation'),
            'depth':
            create_camera(self.vehicle, size, fov, left_transform,
                          'sensor.camera.depth'),
        }

        self.frame = None
        self.delta_seconds = 1.0
        self._queues = []
        self._settings = None

        bp = self.world.get_blueprint_library().find('sensor.other.collision')
        self.collision_sensor = world.spawn_actor(bp,
                                                  carla.Transform(),
                                                  attach_to=self.vehicle)

        self.collision_intensity = 0

        def collision_handler(event):
            impulse = event.normal_impulse
            self.collision_intensity = (impulse.x**2 + impulse.y**2 +
                                        impulse.z**2)**0.5

        self.collision_sensor.listen(collision_handler)
# Parameters
hdri_path = "./assets/HDRIs/green_point_park_2k.hdr"

# Scene Building
scene = bpy.data.scenes["Scene"]
world = scene.world

## Reset
utils.clean_objects()

## Object
focus_target_object = set_scene_objects()

## Camera
camera_object = utils.create_camera(location=(0.0, -10.0, 0.0))

utils.add_track_to_constraint(camera_object, focus_target_object)
utils.set_camera_params(camera_object.data,
                        focus_target_object,
                        lens=72,
                        fstop=0.5)

## Lights
utils.build_environment_texture_background(world, hdri_path)

# Render Setting
utils.set_cycles_renderer(scene,
                          resolution_percentage,
                          output_file_path,
                          camera_object,
# Scene Building
scene = bpy.data.scenes["Scene"]
world = scene.world

## Reset
utils.clean_objects()

## Animation
utils.set_animation(scene, fps=24, frame_start=1, frame_end=48)

## Object
focus_target_object = set_scene_objects()

## Camera
camera_object = utils.create_camera(location=(0.0, -12.5, 2.2))

utils.add_track_to_constraint(camera_object, focus_target_object)
utils.set_camera_params(camera_object.data, focus_target_object)

## Background
utils.build_rgb_background(world, rgb=(0.0, 0.0, 0.0, 1.0))

## Composition
utils.build_scene_composition(scene, dispersion=0.0)

print("test")
# Render Setting
utils.set_output_properties(scene, resolution_percentage, output_file_path)
utils.set_cycles_renderer(scene,
                          camera_object,
Ejemplo n.º 4
0
    camera_position, target_position = (3, -10, 8), (0.3, -1.8, 0.5)  # DE
    #camera_position, target_position = (3, -10, 8), (0.3, 0.0, 0.5)  # AT
    #camera_position, target_position = (3, -10, 8), (-0.1, -0.4, 1.0)  # CH
    #camera_position, target_position = (-2, -10, 8), (0.0, -2.6, 1.0)  # GB

    #camera_type, ortho_scale = 'ORTHO', 15
    camera_type, ortho_scale = 'PERSP', 18
    render_idx = 0

    # Remove all elements in scene
    bpy.ops.object.select_all()
    bpy.ops.object.delete(use_global=False)

    # Create scene
    target = utils.create_target(target_position)
    camera = utils.create_camera(camera_position, target=target,
        camera_type=camera_type, ortho_scale=ortho_scale, lens=28)
        #type='ORTHO', ortho_scale=12)
    sun = utils.create_lamp((-5, 5, 10), 'SUN', target=target)

    # Set background color
    bpy.context.scene.world.color = (0.7, 0.7, 0.7)

    # Ambient occlusion
    bpy.context.scene.world.light_settings.use_ambient_occlusion = True
    # TODO update below line
    #bpy.context.scene.world.light_settings.samples = 8

    # Load points from existing geojson file or load them with Overpass API
    filepath = 'total_flexfare.json'.format(iso_a2, tag_key, tag_value)
    if os.path.exists(filepath):
        points, names = utils_osm.load_points(filepath)
Ejemplo n.º 5
0
    bm.free()
    obj = bpy.data.objects.new("Voronoi", me)
    bpy.context.scene.collection.objects.link(obj)

    # Create and assign materials to object
    for color in colors:
        mat = utils.create_material(convert_hsv(color))
        obj.data.materials.append(mat)


if __name__ == '__main__':
    print(__file__)

    # Remove all elements
    utils.remove_all()

    # Create object
    voronoi_landscape()

    # Create camera and lamp
    target = utils.create_target((0, 0, 3))
    utils.create_camera((-8, -12, 11), target, type='ORTHO', ortho_scale=5)
    utils.create_light((5, -5, 10), target=target, type='SUN')

    # Render scene
    utils.render('rendering',
                 'vornoi_landscape',
                 512,
                 512,
                 render_engine='CYCLES')
                    diameter1=r2, diameter2=r2,
                    depth=0.1*r2, matrix=T @ M0 @ M1 @ Rot)
        return bm


if __name__ == '__main__':
    # Remove all elements
    bpy.ops.object.select_all(action="SELECT")
    bpy.ops.object.delete(use_global=False)

    # Creata phyllotaxis flower
    flower = PhyllotaxisFlower(bpy.context.scene)

    # Create camera and lamp
    target = utils.create_target((0, 0, -1.5))
    camera = utils.create_camera((-21.0, -21.0, 12.5), target, 35)
    sun = utils.create_light((-5, 5, 10), 'SUN', target=target)

    # Select colors
    palette = [(3,101,100), (205,179,128)]
    # Convert color and apply gamma correction
    palette = [tuple(pow(float(c)/255, 2.2) for c in color)
                for color in palette]

    # Smooth surface and add subsurf modifier
    utils.set_smooth(flower.obj, 2)

    # Set background color of scene
    bpy.context.scene.world.use_nodes = False
    bpy.context.scene.world.color = palette[0]
    # Creata fractal tetrahedron
    bm = bmesh.new()
    tetrahedron_base_points = tetrahedron_points(5)
    recursive_tetrahedron(bm, tetrahedron_base_points, level=4)

    # Create obj and mesh from bmesh object
    mesh = bpy.data.meshes.new("TetrahedronMesh")
    bm.to_mesh(mesh)
    bm.free()
    obj = bpy.data.objects.new("Tetrahedron", mesh)
    bpy.context.collection.objects.link(obj)

    # Create camera and lamp
    target = utils.create_target((0, 0, 1))
    utils.create_camera((-8, 10, 5), target, type='ORTHO', ortho_scale=10)
    utils.create_light((10, -10, 10), target=target, type='SUN', energy=100)

    # Select colors
    palette = [(181, 221, 201, 255), (218, 122, 61, 255)]
    palette = [utils.colorRGB_256(color) for color in palette]  # Adjust color to Blender

    # Set background color of scene
    bpy.context.scene.world.node_tree.nodes["Background"] \
        .inputs[0].default_value = palette[0]

    # Set material for object
    mat = utils.create_material(palette[1])
    obj.data.materials.append(mat)

    # Render scene