示例#1
0
# pytracer!

import camera as ca
import vector as vr
import scene  as sc
import light  as lt 
import raytracer as rt
import film as fm

FOVX = 45.0
FOVY = 45.0
PIXWIDTH = 140
PIXHEIGHT = 100


prims = [sc.make_sphere(vr.make_vector(0.0, 0.0, -4.0), 1.0),
         sc.make_sphere(vr.make_vector(-3.0, -2.0, -11.0), 2.0)]

lights = [lt.make_light(2.5, 4.0, 10.0, 7.0),]


eye = vr.make_vector(0.0, 0.0, 0.0)
up  = vr.make_vector(0.0, 1.0, 0.0)
center = vr.make_vector(0.0, 0.0, -1.0)
geo = ca.make_view_geometry(eye, up, center)
camera = ca.make_camera(eye, geo, PIXWIDTH, PIXHEIGHT, FOVX, FOVY)
film = fm.create_film(PIXWIDTH, PIXHEIGHT)

def pytracer():
    for j in range(PIXHEIGHT):
        for i in range(PIXWIDTH):
示例#2
0
# pytracer!

from camera import make_camera, make_view_geometry
from vector import make_vector
from scene import make_sphere
from light import make_light
from raytracer import get_color
import film as fm

FOVX = 45.0
FOVY = 45.0
PIXWIDTH = 130
PIXHEIGHT = 100

prims = [
        make_sphere(make_vector(-0.2, -0.8, -4.0), 0.5),
        make_sphere(make_vector(-3.0, -2.0, -11.0), 1.0)
        ]

lights = [make_light(2.5, 4.0, 10.0, 7.0),]

eye = make_vector(0.0, 0.0, 1.0)
up  = make_vector(0.0, 1.0, 0.0)
center = make_vector(0.0, 0.0, 0.0)
geo = make_view_geometry(eye, up, center)
camera = make_camera(eye, geo, PIXWIDTH, PIXHEIGHT, FOVX, FOVY)
film = fm.create_film(PIXWIDTH, PIXHEIGHT)

def pytracer():
    for j in range(PIXHEIGHT):
        for i in range(PIXWIDTH):