demos/boxes.py
author Radek Brich <radek.brich@devl.cz>
Sat, 10 May 2008 14:29:37 +0200
branchpyrit
changeset 95 ca7d4c665531
parent 90 f6a72eb99631
permissions -rwxr-xr-x
build script fixes, add ldflags build option update and enhance demos fix bug in 4x grid oversampling warn if writePNG called while compiled without libpng make shapes in ShapeList const and add many other const needed due to snowball effect slightly optimize Camera::makeRayPacket using _mm_shuffle_ps make Vector SIMD vectorization disabled by default (causes problems) fix bug in implicit reflection of transmissive surfaces, when surface's reflection parameter is set to zero
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()
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
     6
rt.setBgColour((1.0,1.0,1.0))
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     7
top = Octree()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     8
rt.setTop(top)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    10
light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.1, 0.3, 0.6))
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    11
light1.castShadows(False)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    12
rt.addLight(light1)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3))
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    15
light2.castShadows(False)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    16
rt.addLight(light2)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    18
mat = Material(colour=(0.7, 0.7, 0.7))
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    19
mat.setReflectivity(0.3)
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    20
mat.setTransmissivity(0.5, 1.5)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
for x in range(8):
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
	for y in range(8):
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
		for z in range(8):
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    24
			box = Box(L=(-3.8+x, -3.8+y, -3.8+z), H=(-3.2+x, -3.2+y, -3.2+z), material=mat)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    25
			rt.addShape(box)
57
1e92c21b9a61 new python demo: boxes
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    27
top.optimize()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    28
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    29
sampler = DefaultSampler(800, 600)
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    30
sampler.setOversample(1)
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    31
rt.setSampler(sampler)
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    32
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    33
rt.setCamera(Camera(eye=(-6,6,-10),lookat=(0,0,0)))
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    34
rt.render()
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    35
sampler.getPixmap().writePNG('boxes-1.png')
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    36
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    37
rt.setCamera(Camera(eye=(-4,3,-5),lookat=(0,0,0)))
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    38
rt.render()
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
    39
sampler.getPixmap().writePNG('boxes-2.png')