Пример #1
0
def initScene():
    global scene
    camera = Camera()
    camera.position = Vector(0, 1, 5)
    camera.point_at = Vector(0, 1, 0)
    scene = Scene(window.width, window.height, camera)
    log.info("Initialized scene with {0}x{1} image, {2}".format(window.width, window.height, camera))

    scene.ambient_light = color.scale(color.WHITE, 0.1)

    light = PointLight()
    light.position = Vector(5, 8, 8)
    log.info("Adding {0} to scene".format(light))
    scene.lights.append(light)

    light2 = PointLight()
    light2.position = Vector(-5, 8, 8)
    log.info("Adding {0} to scene".format(light2))
    scene.lights.append(light2)

    plane = Plane()
    plane.material.color = color.scale(color.WHITE, 0.5)
    plane.material.hardness = 0
    plane.material.specular = 0.5
    plane.material.reflection = 0.1
    log.info("Adding {0} to scene".format(plane))
    scene.shapes.append(plane)

    sphere = Sphere()
    sphere.position = Vector(1, 2, -3)
    sphere.radius = 1
    sphere.material.color = color.RED
    sphere.material.specular = 0.5
    sphere.material.hardness = 50
    sphere.material.reflection = 0.5
    log.info("Adding {0} to scene".format(sphere))
    scene.shapes.append(sphere)

    sphere2 = Sphere()
    sphere2.position = Vector(-1, 1, -1.5)
    sphere2.radius = 1
    sphere2.material.color = color.YELLOW
    sphere2.material.specular = 0.5
    sphere2.material.hardness = 50
    sphere2.material.reflection = 0.5
    log.info("Adding {0} to scene".format(sphere2))
    scene.shapes.append(sphere2)