187 int main(int argc, char **argv) |
187 int main(int argc, char **argv) |
188 { |
188 { |
189 Raytracer rt; |
189 Raytracer rt; |
190 |
190 |
191 Octree top; |
191 Octree top; |
|
192 rt.setCamera(&cam); |
192 rt.setTop(&top); |
193 rt.setTop(&top); |
193 |
194 |
194 rt.addlight(&light); |
195 rt.addLight(&light); |
195 light.castShadows(false); |
196 light.castShadows(false); |
196 |
197 |
197 Material mat0a(Colour(0.7, 0.7, 0.7)); |
198 Material mat0a(Colour(0.7, 0.7, 0.7)); |
198 mat0a. setReflectivity(0.0); |
199 mat0a. setReflectivity(0.0); |
199 Box box(Vector3(-12.0, -1.2, -20.0), Vector3(12.0, -1.0, 0.0), &mat0a); |
200 Box box(Vector3(-12.0, -1.2, -20.0), Vector3(12.0, -1.0, 0.0), &mat0a); |
200 rt.addshape(&box); |
201 rt.addShape(&box); |
201 |
202 |
202 Material mat0b(Colour(0.1, 0.7, 0.8)); |
203 Material mat0b(Colour(0.1, 0.7, 0.8)); |
203 mat0b.setReflectivity(0.7); |
204 mat0b.setReflectivity(0.7); |
204 Box box2(Vector3(-12.0, -1.2, -10.0), Vector3(12.0, 10.0, -10.2), &mat0b); |
205 Box box2(Vector3(-12.0, -1.2, -10.0), Vector3(12.0, 10.0, -10.2), &mat0b); |
205 rt.addshape(&box2); |
206 rt.addShape(&box2); |
206 |
207 |
207 // spheres |
208 // spheres |
208 Material mat1(Colour(1.0, 1.0, 1.0)); |
209 Material mat1(Colour(1.0, 1.0, 1.0)); |
209 mat1.texture = new PlanarMapTexture(Vector3(4.0, 2.0, -7.0)); |
210 mat1.texture = new PlanarMapTexture(Vector3(-4.5, 2.0, -7.0)); |
210 Sphere sphere1(Vector3(4.0, 2.0, -7.0), 1.0, &mat1); |
211 Sphere sphere1(Vector3(-4.5, 2.0, -7.0), 1.0, &mat1); |
211 rt.addshape(&sphere1); |
212 rt.addShape(&sphere1); |
212 |
213 |
213 Material mat2(Colour(1.0, 1.0, 1.0)); |
214 Material mat2(Colour(1.0, 1.0, 1.0)); |
214 mat2.texture = new CubicMapTexture(Vector3(1.0, 2.0, -7.0)); |
215 mat2.texture = new CubicMapTexture(Vector3(-1.5, 2.0, -7.0)); |
215 Sphere sphere2(Vector3(1.0, 2.0, -7.0), 1.0, &mat2); |
216 Sphere sphere2(Vector3(-1.5, 2.0, -7.0), 1.0, &mat2); |
216 rt.addshape(&sphere2); |
217 rt.addShape(&sphere2); |
217 |
218 |
218 Material mat3(Colour(1.0, 1.0, 1.0)); |
219 Material mat3(Colour(1.0, 1.0, 1.0)); |
219 mat3.texture = new CylinderMapTexture(Vector3(-2.0, 2.0, -7.0)); |
220 mat3.texture = new CylinderMapTexture(Vector3(1.5, 2.0, -7.0)); |
220 Sphere sphere3(Vector3(-2.0, 2.0, -7.0), 1.0, &mat3); |
221 Sphere sphere3(Vector3(1.5, 2.0, -7.0), 1.0, &mat3); |
221 rt.addshape(&sphere3); |
222 rt.addShape(&sphere3); |
222 |
223 |
223 Material mat4(Colour(1.0, 1.0, 1.0)); |
224 Material mat4(Colour(1.0, 1.0, 1.0)); |
224 mat4.texture = new SphereMapTexture(Vector3(-5.0, 2.0, -7.0)); |
225 mat4.texture = new SphereMapTexture(Vector3(4.5, 2.0, -7.0)); |
225 Sphere sphere4(Vector3(-5.0, 2.0, -7.0), 1.0, &mat4); |
226 Sphere sphere4(Vector3(4.5, 2.0, -7.0), 1.0, &mat4); |
226 rt.addshape(&sphere4); |
227 rt.addShape(&sphere4); |
227 |
228 |
228 // cubes |
229 // cubes |
229 Material mat5(Colour(1.0, 1.0, 1.0)); |
230 Material mat5(Colour(1.0, 1.0, 1.0)); |
230 mat5.texture = new PlanarMapTexture(Vector3(4.0, 0.0, -7.0)); |
231 mat5.texture = new PlanarMapTexture(Vector3(-4.5, 0.0, -7.0)); |
231 Box cube1(Vector3(4.0, 0.0, -7.0)-1.0, Vector3(4.0, 0.0, -7.0)+1.0, &mat5); |
232 Box cube1(Vector3(-4.5, 0.0, -7.0)-1.0, Vector3(-4.5, 0.0, -7.0)+1.0, &mat5); |
232 rt.addshape(&cube1); |
233 rt.addShape(&cube1); |
233 |
234 |
234 Material mat6(Colour(1.0, 1.0, 1.0)); |
235 Material mat6(Colour(1.0, 1.0, 1.0)); |
235 mat6.texture = new CubicMapTexture(Vector3(1.0, 0.0, -7.0)); |
236 mat6.texture = new CubicMapTexture(Vector3(-1.5, 0.0, -7.0)); |
236 Box cube2(Vector3(1.0, 0.0, -7.0)-1.0, Vector3(1.0, 0.0, -7.0)+1.0, &mat6); |
237 Box cube2(Vector3(-1.5, 0.0, -7.0)-1.0, Vector3(-1.5, 0.0, -7.0)+1.0, &mat6); |
237 rt.addshape(&cube2); |
238 rt.addShape(&cube2); |
238 |
239 |
239 Material mat7(Colour(1.0, 1.0, 1.0)); |
240 Material mat7(Colour(1.0, 1.0, 1.0)); |
240 mat7.texture = new CylinderMapTexture(Vector3(-2.0, 0.0, -7.0)); |
241 mat7.texture = new CylinderMapTexture(Vector3(1.5, 0.0, -7.0)); |
241 Box cube3(Vector3(-2.0, 0.0, -7.0)-1.0, Vector3(-2.0, 0.0, -7.0)+1.0, &mat7); |
242 Box cube3(Vector3(1.5, 0.0, -7.0)-1.0, Vector3(1.5, 0.0, -7.0)+1.0, &mat7); |
242 rt.addshape(&cube3); |
243 rt.addShape(&cube3); |
243 |
244 |
244 Material mat8(Colour(1.0, 1.0, 1.0)); |
245 Material mat8(Colour(1.0, 1.0, 1.0)); |
245 mat8.texture = new SphereMapTexture(Vector3(-5.0, 0.0, -7.0)); |
246 mat8.texture = new SphereMapTexture(Vector3(4.5, 0.0, -7.0)); |
246 Box cube4(Vector3(-5.0, 0.0, -7.0)-1.0, Vector3(-5.0, 0.0, -7.0)+1.0, &mat8); |
247 Box cube4(Vector3(4.5, 0.0, -7.0)-1.0, Vector3(4.5, 0.0, -7.0)+1.0, &mat8); |
247 rt.addshape(&cube4); |
248 rt.addShape(&cube4); |
248 |
249 |
249 mat1.setReflectivity(0); |
250 mat1.setReflectivity(0); |
250 mat2.setReflectivity(0); |
251 mat2.setReflectivity(0); |
251 mat3.setReflectivity(0); |
252 mat3.setReflectivity(0); |
252 mat4.setReflectivity(0); |
253 mat4.setReflectivity(0); |