5 from math import * |
5 from math import * |
6 |
6 |
7 rt = Raytracer() |
7 rt = Raytracer() |
8 top = KdTree() |
8 top = KdTree() |
9 rt.setTop(top) |
9 rt.setTop(top) |
10 cam = Camera(eye=(0.,2.,8.)) |
10 rt.setBgColour((0.2,0.3,0.8)) |
|
11 cam = Camera(eye=(-5,3,5),lookat=(-1,1.5,0)) |
11 rotx=0.15 |
12 rotx=0.15 |
12 cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
13 cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
13 rt.setCamera(cam) |
14 rt.setCamera(cam) |
14 |
15 |
15 LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4, trans=(-0.2,0,0.3)) |
16 LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4) |
|
17 |
|
18 mat = Material(colour=(0.5, 0.5, 0.5)) |
|
19 ground = Box(L=(-10,-2,-10), H=(10,-1.2,10), material=mat) |
|
20 rt.addShape(ground) |
|
21 |
|
22 wall = Box(L=(-10,-2,-4), H=(10,10,-3), material=mat) |
|
23 rt.addShape(wall) |
16 |
24 |
17 light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) |
25 light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) |
18 rt.addLight(light1) |
26 rt.addLight(light1) |
19 light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) |
27 light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) |
20 rt.addLight(light2) |
28 rt.addLight(light2) |
21 |
29 |
22 top.optimize() |
30 top.optimize() |
23 |
31 |
24 sampler = DefaultSampler(800, 600) |
32 sampler = DefaultSampler(800, 600) |
|
33 sampler.setOversample(2) |
25 rt.setSampler(sampler) |
34 rt.setSampler(sampler) |
26 rt.render() |
35 rt.render() |
27 sampler.getPixmap().writePNG('car.png') |
36 sampler.getPixmap().writePNG('car.png') |