Exemplo n.º 1
0
def default_world():
    w = world()
    w.light = point_light(point(-10, 10, -10), color(1, 1, 1))
    s1 = sphere()
    s1.material.color = color(0.8, 1.0, 0.6)
    s1.material.diffuse = 0.7
    s1.material.specular = 0.2
    w.objects.append(s1)
    s2 = sphere()
    s2.transform = scaling(0.5, 0.5, 0.5)
    w.objects.append(s2)
    return w
Exemplo n.º 2
0
from camera import camera, render
from canvas import canvas_to_ppm
from material import material
from matrix import scaling, translation, view_transform
from plane import plane
from sphere import sphere
from tuple import color, point, point_light, vector
from world import world

if __name__ == "__main__":
    start = time.time()
    print("Starting render...")

    w = world()
    w.light = point_light(point(-10, 10, -10), color(1, 1, 1))

    floor = plane()
    floor.transform = scaling(10, 0.01, 10)
    floor.material.color = color(1, 0.9, 0.9)
    floor.material.specular = 0
    w.objects.append(floor)

    # left_wall = sphere()
    # left_wall.transform = translation(0, 0, 5) * rotation_y(-pi/4) * rotation_x(pi/2) * scaling(10, 0.01, 10)
    # left_wall.material = floor.material
    # w.objects.append(left_wall)

    # right_wall = sphere()
    # right_wall.transform = translation(0, 0, 5) * rotation_y(pi/4) * rotation_x(pi/2) * scaling(10, 0.01, 10)
    # right_wall.material = floor.material
Exemplo n.º 3
0
if __name__ == "__main__":
    ray_origin = point(0, 0, -5)
    wall_z = 10
    wall_size = 7
    canvas_pixels = 400
    pixel_size = wall_size / canvas_pixels
    half = wall_size / 2

    canvas = canvas(canvas_pixels, canvas_pixels)
    shape = sphere()
    shape.material = material()
    shape.material.color = color(0.2, 1, 1)

    light_position = point(-10, 10, -10)
    light_color = color(1, 1, 1)
    light = point_light(light_position, light_color)

    # transformations
    # shape.transform = scaling(1, 0.5, 1)
    # shape.transform = scaling(0.5, 1, 1)
    # shape.transform = rotation_z(pi / 4) * scaling(0.5, 1, 1)
    # shape.transform = shearing(1, 0, 0, 0, 0, 0) * scaling(0.5, 1, 1)

    start = time.time()
    print("Starting render...")

    for y in range(canvas_pixels):

        world_y = half - pixel_size * y

        for x in range(canvas_pixels):
Exemplo n.º 4
0
def step_impl(context):
    context.light = point_light(context.position, context.intensity)
Exemplo n.º 5
0
def step_impl(context):
    context.light = point_light(point(0, 10, -10), color(1, 1, 1))
Exemplo n.º 6
0
def step_impl(context):
    context.w.light = point_light(point(0, 0, 0), color(1, 1, 1))