author | Radek Brich <radek.brich@devl.cz> |
Thu, 15 May 2008 00:07:25 +0200 | |
branch | pyrit |
changeset 96 | 9eb71e76c7fd |
parent 90 | f6a72eb99631 |
permissions | -rwxr-xr-x |
58 | 1 |
#!/usr/bin/python |
2 |
||
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
3 |
from pyrit import * |
58 | 4 |
from lworeader import LoadLightwaveLwoFile |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
5 |
from math import * |
58 | 6 |
|
7 |
rt = Raytracer() |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
8 |
top = KdTree() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
9 |
rt.setTop(top) |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
10 |
rt.setBgColour((0.2,0.3,0.8)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
11 |
cam = Camera(eye=(-5,3,5),lookat=(-1,1.5,0)) |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
12 |
rotx=0.15 |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
13 |
cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
14 |
rt.setCamera(cam) |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
15 |
|
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
16 |
LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
17 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
18 |
mat = Material(colour=(0.5, 0.5, 0.5)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
19 |
ground = Box(L=(-10,-2,-10), H=(10,-1.2,10), material=mat) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
20 |
rt.addShape(ground) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
21 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
22 |
wall = Box(L=(-10,-2,-4), H=(10,10,-3), material=mat) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
23 |
rt.addShape(wall) |
58 | 24 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
25 |
light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
26 |
rt.addLight(light1) |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
27 |
light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
28 |
rt.addLight(light2) |
58 | 29 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
30 |
top.optimize() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
31 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
32 |
sampler = DefaultSampler(800, 600) |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
33 |
sampler.setOversample(2) |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
34 |
rt.setSampler(sampler) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
35 |
rt.render() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
36 |
sampler.getPixmap().writePNG('car.png') |