9 { |
9 { |
10 Raytracer rt; |
10 Raytracer rt; |
11 KdTree top; |
11 KdTree top; |
12 Camera cam; |
12 Camera cam; |
13 |
13 |
14 rt.setMaxDepth(3); |
14 rt.setMaxDepth(2); |
15 rt.setTop(&top); |
15 rt.setTop(&top); |
16 |
16 |
17 Light light1(Vector(2.0f, -5.0f, -5.0f), Colour(0.7f, 0.3f, 0.6f)); |
17 Light light1(Vector(2.0f, -5.0f, -5.0f), Colour(0.2f, 0.3f, 0.8f)); |
18 light1.castShadows(false); |
18 light1.castShadows(false); |
19 rt.addLight(&light1); |
19 rt.addLight(&light1); |
20 |
20 |
21 Light light2(Vector(-2.0f, 10.0f, 2.0f), Colour(0.4f, 0.6f, 0.3f)); |
21 Light light2(Vector(-2.0f, 10.0f, 2.0f), Colour(0.5f, 0.6f, 0.3f)); |
22 light2.castShadows(false); |
22 light2.castShadows(false); |
23 rt.addLight(&light2); |
23 rt.addLight(&light2); |
24 |
24 |
25 Material mat_sph(Colour(1.0f, 1.0f, 1.0f)); |
25 Material mat_sph(Colour(1.0f, 1.0f, 1.0f)); |
|
26 mat_sph.setPhong(0.2f, 0.9f, 0.0f, 1.0f); |
|
27 mat_sph.setReflectivity(0.3f); |
26 for (int y=0; y<10; y++) |
28 for (int y=0; y<10; y++) |
27 for (int x=0; x<10; x++) |
29 for (int x=0; x<10; x++) |
28 rt.addShape(new Sphere(Vector(x*2-10, (Float)rand()/RAND_MAX*5.0f, y*2-10), 0.45f, &mat_sph)); |
30 rt.addShape(new Sphere(Vector((Float)x*2-10, (Float)rand()/RAND_MAX*5.0f, (Float)y*2-10), 0.45f, &mat_sph)); |
29 |
31 |
30 rt.setCamera(&cam); |
32 rt.setCamera(&cam); |
31 cam.setEye(Vector(0,0,10)); |
33 cam.setEye(Vector(0,0,10)); |
32 |
34 |
33 top.optimize(); |
35 top.optimize(); |