| author | Radek Brich <radek.brich@devl.cz> | 
| Thu, 10 Apr 2008 23:20:36 +0200 | |
| branch | pyrit | 
| changeset 65 | 242839c6d27d | 
| parent 60 | a23b5089b9c3 | 
| child 72 | 7c3f38dff082 | 
| permissions | -rw-r--r-- | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
1  | 
#include "raytracer.h"  | 
| 
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
 | 
2  | 
#include "octree.h"  | 
| 
 
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
 | 
3  | 
|
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
4  | 
#include "image.h"  | 
| 
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
 | 
5  | 
#include "common_sdl.h"  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
6  | 
|
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
7  | 
Camera cam;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
8  | 
Light light(Vector3(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9));  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
9  | 
|
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
10  | 
Float lx, ly, lz, cf;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
11  | 
|
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
12  | 
void update_callback()  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
13  | 
{
 | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
14  | 
if (lx != 0.0)  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
15  | 
light.pos.x += lx;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
16  | 
if (ly != 0.0)  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
17  | 
light.pos.y += ly;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
18  | 
if (lz != 0.0)  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
19  | 
light.pos.z += lz;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
20  | 
if (cf != 0.0)  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
21  | 
cam.f += cf;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
22  | 
}  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
23  | 
|
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
24  | 
void key_callback(int key, int down)  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
25  | 
{
 | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
26  | 
switch (key)  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
27  | 
	{
 | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
28  | 
case SDLK_r:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
29  | 
lx = -0.1 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
30  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
31  | 
case SDLK_t:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
32  | 
lx = +0.1 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
33  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
34  | 
case SDLK_f:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
35  | 
ly = -0.1 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
36  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
37  | 
case SDLK_g:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
38  | 
ly = +0.1 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
39  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
40  | 
case SDLK_v:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
41  | 
lz = -0.1 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
42  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
43  | 
case SDLK_b:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
44  | 
lz = +0.1 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
45  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
46  | 
|
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
47  | 
case SDLK_z:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
48  | 
cf = -0.02 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
49  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
50  | 
case SDLK_x:  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
51  | 
cf = +0.02 * down;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
52  | 
break;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
53  | 
}  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
54  | 
}  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
55  | 
|
| 
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
 | 
56  | 
int main(int argc, char **argv)  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
57  | 
{
 | 
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
58  | 
Raytracer rt;  | 
| 22 | 59  | 
|
| 
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
 | 
60  | 
Octree top;  | 
| 22 | 61  | 
rt.setTop(&top);  | 
| 
16
 
20bceb605f48
add Raytracer::setThreads()
 
Radek Brich <radek.brich@devl.cz> 
parents: 
15 
diff
changeset
 | 
62  | 
|
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
63  | 
rt.addlight(&light);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
64  | 
|
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
65  | 
//Light light2;  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
66  | 
//light2.colour = Colour(0.7, 0.3, 0.6);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
67  | 
//rt.addlight(&light2);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
68  | 
|
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
69  | 
Material mat0a(Colour(0.7, 0.7, 0.7));  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
70  | 
mat0a. setReflectivity(0.0);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
71  | 
Box box(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, -1.0, 0.0), &mat0a);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
72  | 
rt.addshape(&box);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
73  | 
|
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
74  | 
Material mat0b(Colour(0.1, 0.7, 0.8));  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
75  | 
mat0b.setReflectivity(0.7);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
76  | 
Box box2(Vector3(-10.0, -1.2, -20.0), Vector3(10.0, 10.0, -20.2), &mat0b);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
77  | 
rt.addshape(&box2);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
78  | 
|
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
79  | 
Material mat1(Colour(1.0, 0.0, 0.0));  | 
| 
19
 
4e0955fca797
added Camera, currently w/o Python binding
 
Radek Brich <radek.brich@devl.cz> 
parents: 
16 
diff
changeset
 | 
80  | 
Sphere bigsphere(Vector3(3.0, 2.0, -7.0), 3.0, &mat1);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
81  | 
rt.addshape(&bigsphere);  | 
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
82  | 
|
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
83  | 
Material mat2(Colour(0.0, 1.0, 0.0));  | 
| 
19
 
4e0955fca797
added Camera, currently w/o Python binding
 
Radek Brich <radek.brich@devl.cz> 
parents: 
16 
diff
changeset
 | 
84  | 
Sphere smallsphere(Vector3(-5.5, 1.5, -8.0), 2.0, &mat2);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
85  | 
rt.addshape(&smallsphere);  | 
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
86  | 
|
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
87  | 
Material mat3(Colour(0.0, 0.0, 1.0));  | 
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
88  | 
mat3.setReflectivity(0.1);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
89  | 
mat3.setTransmissivity(0.8, 1.5);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
90  | 
Sphere tinysphere(Vector3(-1.2, 0.0, -2.0), 0.7, &mat3);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
91  | 
rt.addshape(&tinysphere);  | 
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
92  | 
|
| 22 | 93  | 
top.optimize();  | 
94  | 
||
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
95  | 
cam.setEye(Vector3(-2.28908, 4.30992, 12.3051));  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
96  | 
cam.p = Vector3(0.0988566, -0.139543, -0.985269);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
97  | 
cam.u = Vector3(-0.995004, 0, -0.0998334);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
98  | 
cam.v = Vector3(0.0139311, 0.990216, -0.138846);  | 
| 
19
 
4e0955fca797
added Camera, currently w/o Python binding
 
Radek Brich <radek.brich@devl.cz> 
parents: 
16 
diff
changeset
 | 
99  | 
rt.setCamera(&cam);  | 
| 
 
4e0955fca797
added Camera, currently w/o Python binding
 
Radek Brich <radek.brich@devl.cz> 
parents: 
16 
diff
changeset
 | 
100  | 
|
| 
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
 | 
101  | 
w = 800;  | 
| 
 
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
 | 
102  | 
h = 600;  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
103  | 
|
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
104  | 
/* run interactive mode */  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
105  | 
loop_sdl(rt, cam, update_callback, key_callback);  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
106  | 
|
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
107  | 
/* render image */  | 
| 
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
108  | 
if (argc == 2 && !strcmp(argv[1], "-r"))  | 
| 
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
 | 
109  | 
	{
 | 
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
110  | 
pyrit_verbosity = 2;  | 
| 
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
 | 
111  | 
Float *fdata = (Float *) malloc(w*h*3*sizeof(Float));  | 
| 
47
 
320d5d466864
move Sampler classes to sampler.cc
 
Radek Brich <radek.brich@devl.cz> 
parents: 
40 
diff
changeset
 | 
112  | 
DefaultSampler sampler(fdata, w, h);  | 
| 
48
 
a4913301c626
begin moving subsampling and oversampling to Sampler
 
Radek Brich <radek.brich@devl.cz> 
parents: 
47 
diff
changeset
 | 
113  | 
sampler.setOversample(2);  | 
| 
47
 
320d5d466864
move Sampler classes to sampler.cc
 
Radek Brich <radek.brich@devl.cz> 
parents: 
40 
diff
changeset
 | 
114  | 
rt.setSampler(&sampler);  | 
| 
 
320d5d466864
move Sampler classes to sampler.cc
 
Radek Brich <radek.brich@devl.cz> 
parents: 
40 
diff
changeset
 | 
115  | 
rt.render();  | 
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
116  | 
|
| 
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
 | 
117  | 
struct image *img;  | 
| 
 
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
 | 
118  | 
new_image(&img, w, h, 3);  | 
| 
40
 
929aad02c5f2
Makefile: added help and distclean target, plus small fixes
 
Radek Brich <radek.brich@devl.cz> 
parents: 
39 
diff
changeset
 | 
119  | 
|
| 
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
 | 
120  | 
Float *fd = fdata;  | 
| 
60
 
a23b5089b9c3
moving to SCons build system
 
Radek Brich <radek.brich@devl.cz> 
parents: 
48 
diff
changeset
 | 
121  | 
		for (unsigned char *cd = img->data; cd != img->data + w*h*3; cd++, fd++) {
 | 
| 
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
 | 
122  | 
if (*fd > 1.0)  | 
| 
 
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
 | 
123  | 
*cd = 255;  | 
| 
 
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
 | 
124  | 
else  | 
| 
 
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
 | 
125  | 
*cd = (unsigned char)(*fd * 255.0);  | 
| 
 
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
 | 
126  | 
}  | 
| 
 
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
 | 
127  | 
free(fdata);  | 
| 
 
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
 | 
128  | 
		save_png("spheres_shadow.png", img);
 | 
| 
 
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
 | 
129  | 
destroy_image(&img);  | 
| 
15
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
130  | 
}  | 
| 
 
a0a3e334744f
C++ demos: prepare infrastructure, add spheres_shadow.cc
 
Radek Brich <radek.brich@devl.cz> 
parents:  
diff
changeset
 | 
131  | 
}  |