def bunny_base(scene, scene_path, **kwargs):
    camera = lm.load_camera(
        'camera_main', 'pinhole', {
            'position': [-0.191925, 2.961061, 4.171464],
            'center': [-0.185709, 2.478091, 3.295850],
            'up': [0, 1, 0],
            'vfov': 28.841546,
            'aspect': 16 / 9
        })
    scene.add_primitive({'camera': camera.loc()})

    model = lm.load_model(
        'model_obj', 'wavefrontobj',
        {'path': os.path.join(scene_path, 'bunny', 'bunny_with_planes.obj')})
    mat_diffuse_white = lm.load_material('mat_diffuse_white', 'diffuse',
                                         {'Kd': [.8, .8, .8]})

    # floor
    tex = lm.load_texture(
        'tex_floor', 'bitmap',
        {'path': os.path.join(scene_path, 'bunny', 'default.png')})
    mat_floor = lm.load_material('mat_floor', 'diffuse', {'mapKd': tex.loc()})
    scene.add_primitive({
        'mesh': model.make_loc('mesh_2'),
        'material': mat_floor.loc()
    })
    # bunny
    if 'mat_knob' in kwargs:
        scene.add_primitive({
            'mesh': model.make_loc('mesh_1'),
            'material': kwargs['mat_knob']
        })
Beispiel #2
0
def portal_box_dragon_2(scene, scene_path, no_light=False, **kwargs):
    base_path = os.path.join(scene_path, 'dragon_in_box')
    g = lm.load_asset_group('dragon', 'default')

    # Load dragon scene
    camera = lm.load_camera('camera_main',
                            'pinhole',
                            position=[-0.191925, 2.961061, 4.171464],
                            center=[-0.185709, 2.478091, 3.295850],
                            up=[0, 1, 0],
                            vfov=28.841546,
                            aspect=16 / 9)
    scene.add_primitive(camera=camera)

    # Model
    model = g.load_model('model_obj',
                         'wavefrontobj',
                         path=os.path.join(base_path, 'dragon_with_plane.obj'))

    # Floor
    tex = lm.load_texture('tex_floor',
                          'bitmap',
                          path=os.path.join(base_path, 'default.png'))
    mat_floor = lm.load_material('mat_floor', 'diffuse', mapKd=tex)
    scene.add_primitive(mesh=model.make_loc('mesh_2'), material=mat_floor)

    # Dragon
    mat = lm.load_material('mat_ut', 'glossy', Ks=[.8, .8, .8], ax=0.2, ay=0.2)
    #mat_white = g.load_material('mat_white', 'diffuse', Kd=[.8,.8,.8])
    scene.add_primitive(mesh=model.make_loc('mesh_4'), material=mat)

    # Light
    if not no_light:
        Le = 1000
        light_env = g.load_light('light_env', 'envconst', Le=[Le, Le, Le])
        scene.add_primitive(light=light_env)

    # Cube
    mat = g.load_material('mat_white', 'diffuse', Kd=[.8, .8, .8])
    cube = g.load_mesh('cube',
                       'wavefrontobj',
                       path=os.path.join(base_path, 'cube.obj'))
    scene.add_primitive(mesh=cube, material=mat)

    # Lid
    lid = g.load_mesh('lid',
                      'wavefrontobj',
                      path=os.path.join(base_path, 'lid.obj'))
    scene.add_primitive(mesh=lid, material=mat)

    # Portal meshes
    portal_mesh = g.load_mesh('portal',
                              'wavefrontobj',
                              path=os.path.join(base_path, 'portal.obj'))
    portal_mesh_2 = g.load_mesh('portal2',
                                'wavefrontobj',
                                path=os.path.join(base_path, 'portal2.obj'))

    return [portal_mesh, portal_mesh_2]
Beispiel #3
0
def sphere(scene, scene_path):
    camera = lm.load_camera(
        'camera_main', 'pinhole', {
            'position': [0, 2, 5],
            'center': [0, 1, 0],
            'up': [0, 1, 0],
            'vfov': 30,
            'aspect': 16 / 9
        })
    scene.add_primitive({'camera': camera.loc()})

    model = lm.load_model('model_obj', 'wavefrontobj',
                          {'path': os.path.join(scene_path, 'sphere.obj')})
    mat_diffuse_white = lm.load_material('mat_diffuse_white', 'diffuse',
                                         {'Kd': [.8, .8, .8]})

    # floor
    tex = lm.load_texture('tex_floor', 'bitmap',
                          {'path': os.path.join(scene_path, 'default.png')})
    mat_floor = lm.load_material('mat_floor', 'diffuse', {'mapKd': tex.loc()})
    scene.add_primitive({
        'mesh': model.make_loc('mesh_1'),
        'material': mat_floor.loc()
    })
    # sphere
    # mat = lm.load_material('mat_ut', 'glass', {
    #     'Ni': 2
    # })
    mat = lm.load_material('mat_ut', 'mirror', {})
    # mat = mat_diffuse_white
    # mat = lm.load_material('mat_ut', 'mask', {})
    scene.add_primitive({
        'mesh': model.make_loc('mesh_3'),
        'material': mat.loc()
    })

    # Light source
    Ke = 10
    mat_black = lm.load_material('mat_black', 'diffuse', {'Kd': [0, 0, 0]})
    light = lm.load_light('light', 'area', {
        'Ke': [Ke, Ke, Ke],
        'mesh': model.make_loc('mesh_2')
    })
    scene.add_primitive({
        'mesh': model.make_loc('mesh_2'),
        'material': mat_black.loc(),
        'light': light.loc()
    })
Beispiel #4
0
                       }, {
                           'material': mat_glossy.loc(),
                           'weight': 0.4
                       }, {
                           'material': mat_mirror.loc(),
                           'weight': 0.4
                       }])
img = render(scene, 'pt')
display_image(img)

# ### Mixture material with alpha texture
#
# `material::mixture_wavefrontobj`
#
# This material is the default material converted from MTL format of Wavefront OBJ.

tex = lm.load_texture('tex',
                      'bitmap',
                      path=os.path.join(env.scene_path, 'fireplace_room',
                                        'textures', 'leaf.png'))
lm.load_material('mat_ut',
                 'mixture_wavefrontobj',
                 Kd=[.8, .8, .8],
                 mapKd=tex,
                 Ks=[0, 0, 0],
                 ax=0.2,
                 ay=0.2,
                 no_alpha_mask=False)
img = render(scene, 'pt')
display_image(img)