ccdemos/textures.cc
branchpyrit
changeset 72 7c3f38dff082
parent 60 a23b5089b9c3
child 75 20dee9819b17
--- a/ccdemos/textures.cc	Sat Apr 19 18:00:27 2008 +0200
+++ b/ccdemos/textures.cc	Sun Apr 20 16:48:24 2008 +0200
@@ -4,7 +4,7 @@
 #include "image.h"
 #include "common_sdl.h"
 
-Camera cam;
+Camera cam(Vector3(0.,6.,6.), Vector3(0.,2.,-7.), Vector3(0.,0.,-1.));
 Light light(Vector3(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9));
 
 Float lx, ly, lz, cf;
@@ -149,7 +149,7 @@
 	if (lz != 0.0)
 		light.pos.z += lz;
 	if (cf != 0.0)
-		cam.f += cf;
+		cam.F += cf;
 }
 
 void key_callback(int key, int down)
@@ -189,62 +189,63 @@
 	Raytracer rt;
 
 	Octree top;
+	rt.setCamera(&cam);
 	rt.setTop(&top);
 
-	rt.addlight(&light);
+	rt.addLight(&light);
 	light.castShadows(false);
 
 	Material mat0a(Colour(0.7, 0.7, 0.7));
 	mat0a. setReflectivity(0.0);
 	Box box(Vector3(-12.0, -1.2, -20.0), Vector3(12.0, -1.0, 0.0), &mat0a);
-	rt.addshape(&box);
+	rt.addShape(&box);
 
 	Material mat0b(Colour(0.1, 0.7, 0.8));
 	mat0b.setReflectivity(0.7);
 	Box box2(Vector3(-12.0, -1.2, -10.0), Vector3(12.0, 10.0, -10.2), &mat0b);
-	rt.addshape(&box2);
+	rt.addShape(&box2);
 
 	// spheres
 	Material mat1(Colour(1.0, 1.0, 1.0));
-	mat1.texture = new PlanarMapTexture(Vector3(4.0, 2.0, -7.0));
-	Sphere sphere1(Vector3(4.0, 2.0, -7.0), 1.0, &mat1);
-	rt.addshape(&sphere1);
+	mat1.texture = new PlanarMapTexture(Vector3(-4.5, 2.0, -7.0));
+	Sphere sphere1(Vector3(-4.5, 2.0, -7.0), 1.0, &mat1);
+	rt.addShape(&sphere1);
 
 	Material mat2(Colour(1.0, 1.0, 1.0));
-	mat2.texture = new CubicMapTexture(Vector3(1.0, 2.0, -7.0));
-	Sphere sphere2(Vector3(1.0, 2.0, -7.0), 1.0, &mat2);
-	rt.addshape(&sphere2);
+	mat2.texture = new CubicMapTexture(Vector3(-1.5, 2.0, -7.0));
+	Sphere sphere2(Vector3(-1.5, 2.0, -7.0), 1.0, &mat2);
+	rt.addShape(&sphere2);
 
 	Material mat3(Colour(1.0, 1.0, 1.0));
-	mat3.texture = new CylinderMapTexture(Vector3(-2.0, 2.0, -7.0));
-	Sphere sphere3(Vector3(-2.0, 2.0, -7.0), 1.0, &mat3);
-	rt.addshape(&sphere3);
+	mat3.texture = new CylinderMapTexture(Vector3(1.5, 2.0, -7.0));
+	Sphere sphere3(Vector3(1.5, 2.0, -7.0), 1.0, &mat3);
+	rt.addShape(&sphere3);
 
 	Material mat4(Colour(1.0, 1.0, 1.0));
-	mat4.texture = new SphereMapTexture(Vector3(-5.0, 2.0, -7.0));
-	Sphere sphere4(Vector3(-5.0, 2.0, -7.0), 1.0, &mat4);
-	rt.addshape(&sphere4);
+	mat4.texture = new SphereMapTexture(Vector3(4.5, 2.0, -7.0));
+	Sphere sphere4(Vector3(4.5, 2.0, -7.0), 1.0, &mat4);
+	rt.addShape(&sphere4);
 
 	// cubes
 	Material mat5(Colour(1.0, 1.0, 1.0));
-	mat5.texture = new PlanarMapTexture(Vector3(4.0, 0.0, -7.0));
-	Box cube1(Vector3(4.0, 0.0, -7.0)-1.0, Vector3(4.0, 0.0, -7.0)+1.0, &mat5);
-	rt.addshape(&cube1);
+	mat5.texture = new PlanarMapTexture(Vector3(-4.5, 0.0, -7.0));
+	Box cube1(Vector3(-4.5, 0.0, -7.0)-1.0, Vector3(-4.5, 0.0, -7.0)+1.0, &mat5);
+	rt.addShape(&cube1);
 
 	Material mat6(Colour(1.0, 1.0, 1.0));
-	mat6.texture = new CubicMapTexture(Vector3(1.0, 0.0, -7.0));
-	Box cube2(Vector3(1.0, 0.0, -7.0)-1.0, Vector3(1.0, 0.0, -7.0)+1.0, &mat6);
-	rt.addshape(&cube2);
+	mat6.texture = new CubicMapTexture(Vector3(-1.5, 0.0, -7.0));
+	Box cube2(Vector3(-1.5, 0.0, -7.0)-1.0, Vector3(-1.5, 0.0, -7.0)+1.0, &mat6);
+	rt.addShape(&cube2);
 
 	Material mat7(Colour(1.0, 1.0, 1.0));
-	mat7.texture = new CylinderMapTexture(Vector3(-2.0, 0.0, -7.0));
-	Box cube3(Vector3(-2.0, 0.0, -7.0)-1.0, Vector3(-2.0, 0.0, -7.0)+1.0, &mat7);
-	rt.addshape(&cube3);
+	mat7.texture = new CylinderMapTexture(Vector3(1.5, 0.0, -7.0));
+	Box cube3(Vector3(1.5, 0.0, -7.0)-1.0, Vector3(1.5, 0.0, -7.0)+1.0, &mat7);
+	rt.addShape(&cube3);
 
 	Material mat8(Colour(1.0, 1.0, 1.0));
-	mat8.texture = new SphereMapTexture(Vector3(-5.0, 0.0, -7.0));
-	Box cube4(Vector3(-5.0, 0.0, -7.0)-1.0, Vector3(-5.0, 0.0, -7.0)+1.0, &mat8);
-	rt.addshape(&cube4);
+	mat8.texture = new SphereMapTexture(Vector3(4.5, 0.0, -7.0));
+	Box cube4(Vector3(4.5, 0.0, -7.0)-1.0, Vector3(4.5, 0.0, -7.0)+1.0, &mat8);
+	rt.addShape(&cube4);
 
 	mat1.setReflectivity(0);
 	mat2.setReflectivity(0);
@@ -257,12 +258,6 @@
 
 	top.optimize();
 
-	cam.setEye(Vector3(-0.530505, 11.0964, 11.2208));
-	cam.p = Vector3(-4.18144e-08, -0.461779, -0.886995);
-	cam.u = Vector3(-1, 0, 6.3393e-11);
-	cam.v = Vector3(3.19387e-08, 0.886995, -0.461779);
-	rt.setCamera(&cam);
-
 	w = 1024;
 	h = 600;