Пример #1
0
def hexagon_edge():
    edge = cylinder()
    edge.minimum = 0
    edge.maximum = 1
    set_transform(
        edge,
        translation(0, 0, -1) * rotation_y(-pi / 6) * rotation_z(-pi / 2) *
        scaling(0.25, 1, 0.25),
    )
    return edge
Пример #2
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
Пример #3
0
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
    # w.objects.append(right_wall)

    middle = sphere()
Пример #4
0
def step_impl(context):
    context.transform = scaling(-1, 1, 1)
Пример #5
0
def step_impl(context):
    context.transform = scaling(2, 3, 4)
Пример #6
0
def step_impl(context):
    assert context.t == scaling(-1, 1, -1)
Пример #7
0
def step_impl(context):
    context.B = scaling(5, 5, 5)
Пример #8
0
def step_impl(context):
    context.A = glass_sphere()
    context.A.transform = scaling(2, 2, 2)
    context.A.material.refractive_index = 1.5
Пример #9
0
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))

    black = color(0, 0, 0)
    white = color(1, 1, 1)

    floor = plane()
    floor.transform = scaling(0.75, 0.75, 0.75)
    floor.material.color = color(0.9, 0.9, 0.9)
    floor.material.specular = 0.1
    floor.material.pattern = checkers_pattern(color(1, 0.8, 0.1),
                                              color(0.1, 0.1, 0.85))
    floor.material.reflective = 0.1
    w.objects.append(floor)

    left_wall = plane()
    left_wall.transform = (translation(0, 0, 5) * rotation_y(-pi / 4) *
                           rotation_x(pi / 2) * scaling(0.25, 0.25, 0.25))
    left_wall.material.specular = 0.1
    left_wall.material.pattern = stripe_pattern(black, white)
    w.objects.append(left_wall)

    right_wall = plane()
Пример #10
0
def hexagon_corner():
    corner = sphere()
    set_transform(corner, translation(0, 0, -1) * scaling(0.25, 0.25, 0.25))
    return corner
Пример #11
0
def step_impl(context):
    context.m = scaling(2, 3, 4)
Пример #12
0
def step_impl(context):
    set_transform(context.g2, scaling(2, 2, 2))
Пример #13
0
def step_impl(context):
    context.m = scaling(1, 0.5, 1) * rotation_z(pi / 5)
Пример #14
0
def step_impl(context):
    set_pattern_transform(context.pattern, scaling(2, 2, 2))
Пример #15
0
def step_impl(context):
    context.s2 = sphere()
    context.s2.transform = scaling(0.5, 0.5, 0.5)