コード例 #1
0
def set_scene():
    cameras = [set_camera()]
    light = set_light()
    # Objects
    objects = []
    # Metallic sphere
    mtl = Material(kr=0.7, specular=0.8)
    shader_type = shaders.TYPE_DIFF_SPECULAR
    radius = 0.2
    pos = np.array([0.6, radius, 1])
    sphere = Sphere(pos, mtl, shader_type, radius)
    # normal_map = ImageTexture(NORMAL_MAP_FILENAME)
    # normal_map.prepare_for_sphere()
    # sphere.add_normal_map(normal_map)
    objects.append(sphere)
    # Mickey sphere
    radius = 0.4
    pos = np.array([-0.4, radius, 1.5])
    mtl = Material(material_type=material.TYPE_TEXTURED, specular=0.5)
    shader_type = shaders.TYPE_DIFF_SPECULAR
    texture = ImageTexture(MICKEY_FILENAME)
    box_size = 1.8 * radius
    box = Box(pos, box_size, box_size, box_size)
    mtl.add_texture(SolidImageTexture(texture, box))
    sphere = Sphere(pos, mtl, shader_type, radius)
    objects.append(sphere)
    create_cube(objects)

    return Scene(cameras, [light], objects)
コード例 #2
0
def set_scene():
    pos = np.array([0.0, 0.0, 0])
    mat = Material(material_type=TYPE_TEXTURED)
    texture = ImageTexture("../textures/checkers.png")
    mat.add_texture(texture)
    # Normal of the plane
    n = np.array([0.0, 1.0, 0.0])
    # n0 vector of the plane (vector lying in the plane)
    n0 = np.array([1.0, 0.0, 0.0])
    # Scale for the texture in x and y
    sx = 4
    sy = 4
    plane = Plane(pos, mat, shaders.TYPE_FLAT, n, n0, sx, sy)
    cameras = [set_camera()]
    return Scene(cameras, [], [plane])
コード例 #3
0
ファイル: main.py プロジェクト: HenrYxZ/sombra
def setup_objects():
    # Plane Object
    plane_pos = np.array([0, -25, 0], dtype=float)
    plane_n0 = np.array([1, 0, 0], dtype=float)
    plane_mtl = Material(
        material.COLOR_GRAY, material.TYPE_TEXTURED, kr=0.4, roughness=0.06
        # material.COLOR_GRAY, material.TYPE_DIFFUSE
    )
    plane_shader = shaders.TYPE_DIFFUSE_COLORS
    plane_normal = np.array([0, 1, 0], dtype=float)
    plane_texture = ImageTexture(CHECKERS_TEXTURE_FILENAME)
    plane_mtl.add_texture(plane_texture)
    plane_sx = 250
    plane_sy = 250
    plane = Plane(
        plane_pos,
        plane_mtl,
        plane_shader,
        plane_normal,
        plane_n0,
        plane_sx,
        plane_sy
    )
    # Sphere Object
    sphere_pos = np.array([-50, 0, 100], dtype=float)
    sphere_mtl = Material(
        material.COLOR_BLUE,
        material.TYPE_TEXTURED,
        specular=DEFAULT_KS
    )
    sphere_mtl.add_texture(ImageTexture(EARTH_HD_TEXTURE_FILENAME))
    sphere_shader = shaders.TYPE_DIFFUSE_COLORS
    sphere_r = 25.0
    sphere = Sphere(sphere_pos, sphere_mtl, sphere_shader, sphere_r)
    # # Mickey Sphere
    # sphere_pos = np.array([-30, -5, 75], dtype=float)
    # sphere_mtl = Material(
    #     material.COLOR_BLUE,
    #     material.TYPE_TEXTURED,
    #     specular=DEFAULT_KS
    # )
    # box = Box(sphere_pos, 40, 40, 40)
    # mickey_img_texture = ImageTexture(MICKEY_TEXTURE_FILENAME)
    # sphere_mtl.add_texture(SolidImageTexture(mickey_img_texture, box))
    # sphere_shader = shaders.TYPE_DIFFUSE_COLORS
    # sphere_r = 20.0
    # mickey = Sphere(sphere_pos, sphere_mtl, sphere_shader, sphere_r)
    # # Gray Sphere
    # sphere_pos = np.array([90, 15, 160], dtype=float)
    # sphere_mtl = Material(
    #     material.COLOR_GRAY,
    #     material.TYPE_DIFFUSE,
    #     specular=DEFAULT_KS,
    #     border=0.0,
    #     kr=0.7, roughness=0.15
    # )
    # sphere_shader = shaders.TYPE_DIFFUSE_COLORS
    # sphere_r = 40.0
    # gray_sphere = Sphere(sphere_pos, sphere_mtl, sphere_shader, sphere_r)
    # return [sphere, plane, mickey, gray_sphere]
    return [sphere, plane]