4 # http://graphics.stanford.edu/data/3Dscanrep/ |
4 # http://graphics.stanford.edu/data/3Dscanrep/ |
5 |
5 |
6 import sys |
6 import sys |
7 sys.path.append(open('ModulePath').read().strip()) |
7 sys.path.append(open('ModulePath').read().strip()) |
8 |
8 |
9 from raytracer import Raytracer, Light, Sphere, Triangle, NormalVertex, Material |
9 from raytracer import Raytracer, Light, Box, Triangle, NormalVertex, Material |
10 from plyreader import LoadStanfordPlyFile |
10 from plyreader import LoadStanfordPlyFile |
11 import Image |
11 import Image |
12 |
12 |
13 rt = Raytracer() |
13 rt = Raytracer() |
|
14 #rt.ambientocclusion(samples=100, distance=16.0, angle=0.5) |
|
15 |
14 mat = Material(colour=(0.9, 0.9, 0.9)) |
16 mat = Material(colour=(0.9, 0.9, 0.9)) |
|
17 mat.setTransmissivity(0.8) |
15 LoadStanfordPlyFile(rt, "../models/bunny/bun_zipper.ply", |
18 LoadStanfordPlyFile(rt, "../models/bunny/bun_zipper.ply", |
16 mat, smooth=True, scale=(-29.0, 29.0, 29.0), trans=(-1,-3,-3)) |
19 mat, smooth=True, scale=(-29.0, 29.0, 29.0), trans=(-1,-2.5,-3)) |
17 |
20 |
18 light = Light(position=(-5.0, 2.0, 10.0), colour=(0.9, 0.3, 0.6)) |
21 mat0 = Material(colour=(0.1, 0.2, 0.9)) |
|
22 box1 = Box(L=(-20.0, -1.7, -20.0), H=(20.0, -1.5, 20.0), material=mat0) |
|
23 rt.addshape(box1) |
|
24 |
|
25 mat1 = Material(colour=(0.2, 0.8, 0.4)) |
|
26 mat1.setReflectivity(0.0) |
|
27 box2 = Box(L=(-20.0, -20.0, -10.0), H=(20.0, 20.0, -12.0), material=mat1) |
|
28 rt.addshape(box2) |
|
29 |
|
30 light = Light(position=(-5.0, 3.0, 10.0), colour=(0.9, 0.3, 0.6)) |
19 rt.addlight(light) |
31 rt.addlight(light) |
20 |
32 |
21 light2 = Light(position=(4.0, -3.0, 10.0), colour=(0.2, 0.9, 0.5)) |
33 light2 = Light(position=(4.0, 1.0, 10.0), colour=(0.2, 0.9, 0.5)) |
22 rt.addlight(light2) |
34 rt.addlight(light2) |
23 |
35 |
24 imagesize = (800, 600) |
36 imagesize = (800, 600) |
25 data = rt.render(imagesize) |
37 data = rt.render(imagesize) |
26 img = Image.fromstring("RGB", imagesize, data) |
38 img = Image.fromstring("RGB", imagesize, data) |