author | Radek Brich <radek.brich@devl.cz> |
Sat, 10 May 2008 14:29:37 +0200 | |
branch | pyrit |
changeset 95 | ca7d4c665531 |
parent 93 | 96d65f841791 |
child 100 | c005054bf4c1 |
permissions | -rw-r--r-- |
40
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
1 |
#include <stdlib.h> |
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
2 |
|
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
#include "raytracer.h" |
74
09aedbf5f95f
kd-tree traversal - avoid dynamic memory allocation
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
4 |
#include "kdtree.h" |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
39
7079dcc3bd74
ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents:
37
diff
changeset
|
6 |
#include "common_sdl.h" |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
|
40
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
8 |
int main(int argc, char **argv) |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
{ |
39
7079dcc3bd74
ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents:
37
diff
changeset
|
10 |
Raytracer rt; |
74
09aedbf5f95f
kd-tree traversal - avoid dynamic memory allocation
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
11 |
KdTree top; |
39
7079dcc3bd74
ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents:
37
diff
changeset
|
12 |
Camera cam; |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
|
93 | 14 |
rt.setMaxDepth(2); |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
rt.setTop(&top); |
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
|
93 | 17 |
Light light1(Vector(2.0f, -5.0f, -5.0f), Colour(0.2f, 0.3f, 0.8f)); |
21
79b516a3803d
naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
18 |
light1.castShadows(false); |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
19 |
rt.addLight(&light1); |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
|
93 | 21 |
Light light2(Vector(-2.0f, 10.0f, 2.0f), Colour(0.5f, 0.6f, 0.3f)); |
21
79b516a3803d
naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
22 |
light2.castShadows(false); |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
23 |
rt.addLight(&light2); |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
|
92
9af5c039b678
add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents:
91
diff
changeset
|
25 |
Material mat_sph(Colour(1.0f, 1.0f, 1.0f)); |
93 | 26 |
mat_sph.setPhong(0.2f, 0.9f, 0.0f, 1.0f); |
27 |
mat_sph.setReflectivity(0.3f); |
|
21
79b516a3803d
naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
28 |
for (int y=0; y<10; y++) |
79b516a3803d
naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
29 |
for (int x=0; x<10; x++) |
93 | 30 |
rt.addShape(new Sphere(Vector((Float)x*2-10, (Float)rand()/RAND_MAX*5.0f, (Float)y*2-10), 0.45f, &mat_sph)); |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
|
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
rt.setCamera(&cam); |
91 | 33 |
cam.setEye(Vector(0,0,10)); |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
|
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
top.optimize(); |
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
|
39
7079dcc3bd74
ccdemos: put the common code to header files, common_ply.h and common_sdl.h
Radek Brich <radek.brich@devl.cz>
parents:
37
diff
changeset
|
37 |
loop_sdl(rt, cam); |
92
9af5c039b678
add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents:
91
diff
changeset
|
38 |
|
9af5c039b678
add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents:
91
diff
changeset
|
39 |
return 0; |
20
f22952603f29
new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
} |