demos/boxes.py
author Radek Brich <radek.brich@devl.cz>
Tue, 06 May 2008 09:39:58 +0200
branchpyrit
changeset 93 96d65f841791
parent 90 f6a72eb99631
child 95 ca7d4c665531
permissions -rwxr-xr-x
more build script tuning make all float constants single precision solve many warnings from msvc and gcc with various -W... flags add common.cc file for dbgmsg() function witch apparently cannot be inlined fix python module building with msvc, add manifest file handling remove forgotten RenderrowData class add stanford models download script for windows (.bat)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/python
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     3
from pyrit import *
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
rt = Raytracer()
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     6
top = Octree()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     7
rt.setTop(top)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     8
rt.setCamera(Camera())
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6))
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    11
rt.addLight(light1)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3))
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    14
rt.addLight(light2)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
mat0 = Material(colour=(0.7, 0.7, 0.7))
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
mat0.setReflectivity(0.0)
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
for x in range(8):
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
	for y in range(8):
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
		for z in range(8):
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
			box = Box(L=(-4.3+x, -4.6+y, -8.6+z), H=(-3.7+x, -4.0+y, -8.0+z), material=mat0)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    22
			rt.addShape(box)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    24
top.optimize()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    25
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    26
sampler = DefaultSampler(800, 600)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    27
rt.setSampler(sampler)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    28
rt.render()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    29
sampler.getPixmap().writePNG('boxes.png')