demos/bunny.py
author Radek Brich <radek.brich@devl.cz>
Mon, 05 May 2008 15:31:14 +0200
branchpyrit
changeset 92 9af5c039b678
parent 90 f6a72eb99631
child 95 ca7d4c665531
permissions -rwxr-xr-x
add MSVC compiler support, make it default for Windows new header file simd.h for SSE abstraction and helpers add mselect pseudo instruction for common or(and(...), andnot(...)) replace many SSE intrinsics with new names new MemoryPool class (mempool.h) for faster KdNode allocation remove setMaxDepth() from Octree and KdTree, make max_depth const, it should be defined in constructor and never changed, change after building tree would cause error in traversal modify DefaultSampler to generate nice 2x2 packets of samples for packet tracing optimize Box and BBox::intersect_packet add precomputed invdir attribute to RayPacket scons build system: check for pthread library on Windows check for SDL generate include/config.h with variables detected by scons configuration move auxiliary files to build/ add sanity checks add writable operator[] to Vector
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/python
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
# this demo needs bunny model from
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
# http://graphics.stanford.edu/data/3Dscanrep/
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     6
from pyrit import *
29
574c34441a1c new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents: 28
diff changeset
     7
from plyreader import LoadStanfordPlyFile
26
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
rt = Raytracer()
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    10
top = KdTree()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    11
rt.setTop(top)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    12
rt.setCamera(Camera())
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    13
31
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    14
#rt.ambientocclusion(samples=100, distance=16.0, angle=0.5)
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    15
26
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
mat = Material(colour=(0.9, 0.9, 0.9))
31
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    17
mat.setTransmissivity(0.8)
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    18
mat.setSmooth(True)
62
07c2f8084719 more SConscript tweaking, make model preparation work again
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    19
LoadStanfordPlyFile(rt, "../models/ply/bunny/bun_zipper.ply",
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    20
	mat, scale=(-29.0, 29.0, 29.0), trans=(-1,-2.5,-3))
31
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    21
46
6493fb65f0b1 Doxygen
Radek Brich <radek.brich@devl.cz>
parents: 40
diff changeset
    22
mat0 = Material(colour=(0.1, 0.2, 0.6))
31
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    23
box1 = Box(L=(-20.0, -1.7, -20.0), H=(20.0, -1.5, 20.0), material=mat0)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    24
rt.addShape(box1)
26
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
46
6493fb65f0b1 Doxygen
Radek Brich <radek.brich@devl.cz>
parents: 40
diff changeset
    26
mat1 = Material(colour=(0.5, 0.5, 0.2))
31
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    27
mat1.setReflectivity(0.0)
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    28
box2 = Box(L=(-20.0, -20.0, -10.0), H=(20.0, 20.0, -12.0), material=mat1)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    29
rt.addShape(box2)
31
b4e09433934a refraction
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    30
46
6493fb65f0b1 Doxygen
Radek Brich <radek.brich@devl.cz>
parents: 40
diff changeset
    31
light = Light(position=(-5.0, 3.0, 10.0), colour=(0.8, 0.5, 0.6))
40
929aad02c5f2 Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents: 38
diff changeset
    32
#light.castshadows(0)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    33
rt.addLight(light)
26
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
46
6493fb65f0b1 Doxygen
Radek Brich <radek.brich@devl.cz>
parents: 40
diff changeset
    35
light2 = Light(position=(4.0, 1.0, 10.0), colour=(0.5, 0.55, 0.7))
40
929aad02c5f2 Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents: 38
diff changeset
    36
#light2.castshadows(0)
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    37
rt.addLight(light2)
26
9073320e9f4c new demo: bunny.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    39
top.optimize()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    40
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    41
sampler = DefaultSampler(800, 600)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    42
rt.setSampler(sampler)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    43
rt.render()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    44
sampler.getPixmap().writePNG('bunny.png')