54 |
54 |
55 int main(int argc, char **argv) |
55 int main(int argc, char **argv) |
56 { |
56 { |
57 Raytracer rt; |
57 Raytracer rt; |
58 |
58 |
59 Octree top; |
59 KdTree top; |
60 rt.setCamera(&cam); |
60 rt.setCamera(&cam); |
61 rt.setTop(&top); |
61 rt.setTop(&top); |
62 |
62 |
63 rt.addLight(&light); |
63 rt.addLight(&light); |
64 light.castShadows(false); |
64 light.castShadows(false); |
65 |
65 |
66 Material mat0a(Colour(0.7, 0.7, 0.7)); |
66 Material mat0a(Colour(0.7, 0.7, 0.7)); |
67 mat0a.setReflectivity(0.0); |
67 mat0a.setReflectivity(0.0); |
68 Box box(Vector3(-12.0, -1.2, -20.0), Vector3(12.0, -1.0, 0.0), &mat0a); |
68 Box box(Vector(-12.0, -1.2, -20.0), Vector(12.0, -1.0, 0.0), &mat0a); |
69 rt.addShape(&box); |
69 rt.addShape(&box); |
70 |
70 |
71 Material mat0b(Colour(0.1, 0.7, 0.8)); |
71 Material mat0b(Colour(0.1, 0.7, 0.8)); |
72 mat0b.setReflectivity(0.7); |
72 mat0b.setReflectivity(0.7); |
73 Box box2(Vector3(-12.0, -1.2, -10.0), Vector3(12.0, 10.0, -10.2), &mat0b); |
73 Box box2(Vector(-12.0, -1.2, -10.0), Vector(12.0, 10.0, -10.2), &mat0b); |
74 rt.addShape(&box2); |
74 rt.addShape(&box2); |
75 |
75 |
76 Float bounds[] = {0.3, 0.6, 1.1}; |
76 Float bounds[] = {0.3, 0.6, 1.1}; |
77 Colour colours[] = {Colour(0,0,0), Colour(1,1,1), Colour(0,0,0)}; |
77 Colour colours[] = {Colour(0,0,0), Colour(1,1,1), Colour(0,0,0)}; |
78 BoundColourMap cmap(bounds, colours); |
78 BoundColourMap cmap(bounds, colours); |
79 |
79 |
80 // spheres |
80 // spheres |
81 Material mat1(Colour(1.0, 1.0, 1.0)); |
81 Material mat1(Colour(1.0, 1.0, 1.0)); |
82 mat1.texture = new CheckersTexture(new PlanarMap(Vector3(-4.5, 2.0, -7.0), 0.48), &cmap); |
82 mat1.texture = new CheckersTexture(new PlanarMap(Vector(-4.5, 2.0, -7.0), 0.48), &cmap); |
83 Sphere sphere1(Vector3(-4.5, 2.0, -7.0), 1.0, &mat1); |
83 Sphere sphere1(Vector(-4.5, 2.0, -7.0), 1.0, &mat1); |
84 rt.addShape(&sphere1); |
84 rt.addShape(&sphere1); |
85 |
85 |
86 Material mat2(Colour(1.0, 1.0, 1.0)); |
86 Material mat2(Colour(1.0, 1.0, 1.0)); |
87 mat2.texture = new CheckersTexture(new CubicMap(Vector3(-1.5, 2.0, -7.0), 0.48), &cmap); |
87 mat2.texture = new CheckersTexture(new CubicMap(Vector(-1.5, 2.0, -7.0), 0.48), &cmap); |
88 Sphere sphere2(Vector3(-1.5, 2.0, -7.0), 1.0, &mat2); |
88 Sphere sphere2(Vector(-1.5, 2.0, -7.0), 1.0, &mat2); |
89 rt.addShape(&sphere2); |
89 rt.addShape(&sphere2); |
90 |
90 |
91 Material mat3(Colour(1.0, 1.0, 1.0)); |
91 Material mat3(Colour(1.0, 1.0, 1.0)); |
92 mat3.texture = new CheckersTexture(new CylinderMap(Vector3(1.5, 2.0, -7.0), 0.48), &cmap); |
92 mat3.texture = new CheckersTexture(new CylinderMap(Vector(1.5, 2.0, -7.0), 0.48), &cmap); |
93 Sphere sphere3(Vector3(1.5, 2.0, -7.0), 1.0, &mat3); |
93 Sphere sphere3(Vector(1.5, 2.0, -7.0), 1.0, &mat3); |
94 rt.addShape(&sphere3); |
94 rt.addShape(&sphere3); |
95 |
95 |
96 Material mat4(Colour(1.0, 1.0, 1.0)); |
96 Material mat4(Colour(1.0, 1.0, 1.0)); |
97 mat4.texture = new CheckersTexture(new SphereMap(Vector3(4.5, 2.0, -7.0), 0.48), &cmap); |
97 mat4.texture = new CheckersTexture(new SphereMap(Vector(4.5, 2.0, -7.0), 0.48), &cmap); |
98 Sphere sphere4(Vector3(4.5, 2.0, -7.0), 1.0, &mat4); |
98 Sphere sphere4(Vector(4.5, 2.0, -7.0), 1.0, &mat4); |
99 rt.addShape(&sphere4); |
99 rt.addShape(&sphere4); |
100 |
100 |
101 // cubes |
101 // cubes |
102 Material mat5(Colour(1.0, 1.0, 1.0)); |
102 Material mat5(Colour(1.0, 1.0, 1.0)); |
103 mat5.texture = new CheckersTexture(new PlanarMap(Vector3(-4.5, 0.0, -7.0), 0.48), &cmap); |
103 mat5.texture = new CheckersTexture(new PlanarMap(Vector(-4.5, 0.0, -7.0), 0.48), &cmap); |
104 Box cube1(Vector3(-4.5, 0.0, -7.0)-1.0, Vector3(-4.5, 0.0, -7.0)+1.0, &mat5); |
104 Box cube1(Vector(-4.5, 0.0, -7.0)-1.0, Vector(-4.5, 0.0, -7.0)+1.0, &mat5); |
105 rt.addShape(&cube1); |
105 rt.addShape(&cube1); |
106 |
106 |
107 Material mat6(Colour(1.0, 1.0, 1.0)); |
107 Material mat6(Colour(1.0, 1.0, 1.0)); |
108 mat6.texture = new CheckersTexture(new CubicMap(Vector3(-1.5, 0.0, -7.0), 0.48), &cmap); |
108 mat6.texture = new CheckersTexture(new CubicMap(Vector(-1.5, 0.0, -7.0), 0.48), &cmap); |
109 Box cube2(Vector3(-1.5, 0.0, -7.0)-1.0, Vector3(-1.5, 0.0, -7.0)+1.0, &mat6); |
109 Box cube2(Vector(-1.5, 0.0, -7.0)-1.0, Vector(-1.5, 0.0, -7.0)+1.0, &mat6); |
110 rt.addShape(&cube2); |
110 rt.addShape(&cube2); |
111 |
111 |
112 Material mat7(Colour(1.0, 1.0, 1.0)); |
112 Material mat7(Colour(1.0, 1.0, 1.0)); |
113 mat7.texture = new CheckersTexture(new CylinderMap(Vector3(1.5, 0.0, -7.0), 0.48), &cmap); |
113 mat7.texture = new CheckersTexture(new CylinderMap(Vector(1.5, 0.0, -7.0), 0.48), &cmap); |
114 Box cube3(Vector3(1.5, 0.0, -7.0)-1.0, Vector3(1.5, 0.0, -7.0)+1.0, &mat7); |
114 Box cube3(Vector(1.5, 0.0, -7.0)-1.0, Vector(1.5, 0.0, -7.0)+1.0, &mat7); |
115 rt.addShape(&cube3); |
115 rt.addShape(&cube3); |
116 |
116 |
117 Material mat8(Colour(1.0, 1.0, 1.0)); |
117 Material mat8(Colour(1.0, 1.0, 1.0)); |
118 mat8.texture = new CheckersTexture(new SphereMap(Vector3(4.5, 0.0, -7.0), 0.48), &cmap); |
118 mat8.texture = new CheckersTexture(new SphereMap(Vector(4.5, 0.0, -7.0), 0.48), &cmap); |
119 Box cube4(Vector3(4.5, 0.0, -7.0)-1.0, Vector3(4.5, 0.0, -7.0)+1.0, &mat8); |
119 Box cube4(Vector(4.5, 0.0, -7.0)-1.0, Vector(4.5, 0.0, -7.0)+1.0, &mat8); |
120 rt.addShape(&cube4); |
120 rt.addShape(&cube4); |
121 |
121 |
122 mat1.setReflectivity(0); |
122 mat1.setReflectivity(0); |
123 mat2.setReflectivity(0); |
123 mat2.setReflectivity(0); |
124 mat3.setReflectivity(0); |
124 mat3.setReflectivity(0); |