ccdemos/textures.cc
branchpyrit
changeset 93 96d65f841791
parent 92 9af5c039b678
child 100 c005054bf4c1
--- a/ccdemos/textures.cc	Mon May 05 15:31:14 2008 +0200
+++ b/ccdemos/textures.cc	Tue May 06 09:39:58 2008 +0200
@@ -3,8 +3,8 @@
 
 #include "common_sdl.h"
 
-Camera cam(Vector(0.,6.,6.), Vector(0.,2.,-7.), Vector(0.,0.,-1.));
-Light light(Vector(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9));
+Camera cam(Vector(0.0f,6.0f,6.0f), Vector(0.0f,2.0f,-7.0f), Vector(0.0f,0.0f,-1.0f));
+Light light(Vector(-2.0f, 10.0f, -2.0f), Colour(0.9f, 0.9f, 0.9f));
 
 Float lx, ly, lz, cf;
 
@@ -25,29 +25,29 @@
 	switch (key)
 	{
 		case SDLK_r:
-			lx = -0.1 * down;
+			lx = -0.1f * down;
 			break;
 		case SDLK_t:
-			lx = +0.1 * down;
+			lx = +0.1f * down;
 			break;
 		case SDLK_f:
-			ly = -0.1 * down;
+			ly = -0.1f * down;
 			break;
 		case SDLK_g:
-			ly = +0.1 * down;
+			ly = +0.1f * down;
 			break;
 		case SDLK_v:
-			lz = -0.1 * down;
+			lz = -0.1f * down;
 			break;
 		case SDLK_b:
-			lz = +0.1 * down;
+			lz = +0.1f * down;
 			break;
 
 		case SDLK_z:
-			cf = -0.02 * down;
+			cf = -0.02f * down;
 			break;
 		case SDLK_x:
-			cf = +0.02 * down;
+			cf = +0.02f * down;
 			break;
 	}
 }
@@ -63,60 +63,67 @@
 	rt.addLight(&light);
 	light.castShadows(false);
 
-	Material mat0a(Colour(0.7, 0.7, 0.7));
-	mat0a.setReflectivity(0.0);
-	Box box(Vector(-12.0, -1.2, -20.0), Vector(12.0, -1.0, 0.0), &mat0a);
+	const Colour c_white(1, 1, 1);
+	const Colour c_black(0, 0, 0);
+
+	Material mat0a(Colour(0.7f, 0.7f, 0.7f));
+	mat0a.setReflectivity(0.0f);
+	Box box(Vector(-12.0f, -1.2f, -20.0f), Vector(12.0f, -1.0f, 0.0f), &mat0a);
 	rt.addShape(&box);
 
-	Material mat0b(Colour(0.1, 0.7, 0.8));
-	mat0b.setReflectivity(0.7);
-	Box box2(Vector(-12.0, -1.2, -10.0), Vector(12.0, 10.0, -10.2), &mat0b);
+	Material mat0b(Colour(0.1f, 0.7f, 0.8f));
+	mat0b.setReflectivity(0.7f);
+	Box box2(Vector(-12.0f, -1.2f, -10.0f), Vector(12.0f, 10.0f, -10.2f), &mat0b);
 	rt.addShape(&box2);
 
-	Float bounds[] = {0.3, 0.6, 1.1};
-	Colour colours[] = {Colour(0,0,0), Colour(1,1,1), Colour(0,0,0)};
+	Float bounds[] = {0.3f, 0.6f, 1.1f};
+	Colour colours[] = {c_black, c_white, c_black};
 	BoundColourMap cmap(bounds, colours);
 
 	// spheres
-	Material mat1(Colour(1.0, 1.0, 1.0));
-	mat1.texture = new CheckersTexture(new PlanarMap(Vector(-4.5, 2.0, -7.0), 0.48), &cmap);
-	Sphere sphere1(Vector(-4.5, 2.0, -7.0), 1.0, &mat1);
+	Material mat1(c_white);
+	mat1.texture = new CheckersTexture(new PlanarMap(Vector(-4.5f, 2.0f, -7.0f), 0.48f), &cmap);
+	Sphere sphere1(Vector(-4.5f, 2.0f, -7.0f), 1, &mat1);
 	rt.addShape(&sphere1);
 
-	Material mat2(Colour(1.0, 1.0, 1.0));
-	mat2.texture = new CheckersTexture(new CubicMap(Vector(-1.5, 2.0, -7.0), 0.48), &cmap);
-	Sphere sphere2(Vector(-1.5, 2.0, -7.0), 1.0, &mat2);
+	Material mat2(c_white);
+	mat2.texture = new CheckersTexture(new CubicMap(Vector(-1.5f, 2.0f, -7.0f), 0.48f), &cmap);
+	Sphere sphere2(Vector(-1.5f, 2.0f, -7.0f), 1, &mat2);
 	rt.addShape(&sphere2);
 
-	Material mat3(Colour(1.0, 1.0, 1.0));
-	mat3.texture = new CheckersTexture(new CylinderMap(Vector(1.5, 2.0, -7.0), 0.48), &cmap);
-	Sphere sphere3(Vector(1.5, 2.0, -7.0), 1.0, &mat3);
+	Material mat3(c_white);
+	mat3.texture = new CheckersTexture(new CylinderMap(Vector(1.5f, 2.0f, -7.0f), 0.48f), &cmap);
+	Sphere sphere3(Vector(1.5f, 2.0f, -7.0f), 1, &mat3);
 	rt.addShape(&sphere3);
 
-	Material mat4(Colour(1.0, 1.0, 1.0));
-	mat4.texture = new CheckersTexture(new SphereMap(Vector(4.5, 2.0, -7.0), 0.48), &cmap);
-	Sphere sphere4(Vector(4.5, 2.0, -7.0), 1.0, &mat4);
+	Material mat4(c_white);
+	mat4.texture = new CheckersTexture(new SphereMap(Vector(4.5f, 2.0f, -7.0f), 0.48f), &cmap);
+	Sphere sphere4(Vector(4.5f, 2.0f, -7.0f), 1, &mat4);
 	rt.addShape(&sphere4);
 
 	// cubes
-	Material mat5(Colour(1.0, 1.0, 1.0));
-	mat5.texture = new CheckersTexture(new PlanarMap(Vector(-4.5, 0.0, -7.0), 0.48), &cmap);
-	Box cube1(Vector(-4.5, 0.0, -7.0)-1.0, Vector(-4.5, 0.0, -7.0)+1.0, &mat5);
+	Material mat5(c_white);
+	const Vector cube1_base(-4.5f, 0.0f, -7.0f);
+	mat5.texture = new CheckersTexture(new PlanarMap(cube1_base, 0.48f), &cmap);
+	Box cube1(cube1_base - 1.0f, cube1_base + 1.0f, &mat5);
 	rt.addShape(&cube1);
 
-	Material mat6(Colour(1.0, 1.0, 1.0));
-	mat6.texture = new CheckersTexture(new CubicMap(Vector(-1.5, 0.0, -7.0), 0.48), &cmap);
-	Box cube2(Vector(-1.5, 0.0, -7.0)-1.0, Vector(-1.5, 0.0, -7.0)+1.0, &mat6);
+	Material mat6(c_white);
+	const Vector cube2_base(-1.5f, 0.0f, -7.0f);
+	mat6.texture = new CheckersTexture(new CubicMap(cube2_base, 0.48f), &cmap);
+	Box cube2(cube2_base - 1.0f, cube2_base + 1.0f, &mat6);
 	rt.addShape(&cube2);
 
-	Material mat7(Colour(1.0, 1.0, 1.0));
-	mat7.texture = new CheckersTexture(new CylinderMap(Vector(1.5, 0.0, -7.0), 0.48), &cmap);
-	Box cube3(Vector(1.5, 0.0, -7.0)-1.0, Vector(1.5, 0.0, -7.0)+1.0, &mat7);
+	Material mat7(c_white);
+	const Vector cube3_base(1.5f, 0.0f, -7.0f);
+	mat7.texture = new CheckersTexture(new CylinderMap(cube3_base, 0.48f), &cmap);
+	Box cube3(cube3_base - 1.0f, cube3_base + 1.0f, &mat7);
 	rt.addShape(&cube3);
 
-	Material mat8(Colour(1.0, 1.0, 1.0));
-	mat8.texture = new CheckersTexture(new SphereMap(Vector(4.5, 0.0, -7.0), 0.48), &cmap);
-	Box cube4(Vector(4.5, 0.0, -7.0)-1.0, Vector(4.5, 0.0, -7.0)+1.0, &mat8);
+	Material mat8(c_white);
+	const Vector cube4_base(4.5f, 0.0f, -7.0f);
+	mat8.texture = new CheckersTexture(new SphereMap(cube4_base, 0.48f), &cmap);
+	Box cube4(cube4_base - 1.0f, cube4_base + 1.0f, &mat8);
 	rt.addShape(&cube4);
 
 	mat1.setReflectivity(0);
@@ -140,7 +147,7 @@
 	if (argc == 2 && !strcmp(argv[1], "-r"))
 	{
 		pyrit_verbosity = 2;
-		rt.ambientOcclusion(300, 5.0, 0.5);
+		rt.ambientOcclusion(300, 5.0f, 0.5f);
 		DefaultSampler sampler(w, h);
 		sampler.setOversample(2);
 		sampler.setSubsample(1);