ccdemos/realtime_dragon.cc
branchpyrit
changeset 80 907929fa9b59
parent 72 7c3f38dff082
child 91 9d66d323c354
--- a/ccdemos/realtime_dragon.cc	Wed Apr 23 14:39:33 2008 +0200
+++ b/ccdemos/realtime_dragon.cc	Wed Apr 23 19:35:03 2008 +0200
@@ -1,5 +1,6 @@
 #include "raytracer.h"
 #include "kdtree.h"
+#include "serialize.h"
 
 #include "common_sdl.h"
 #include "common_ply.h"
@@ -12,6 +13,8 @@
 
 	rt.setMaxDepth(0);
 	rt.setTop(&top);
+	rt.setCamera(&cam);
+	cam.setEye(Vector3(0,0,10));
 
 	Light light1(Vector3(-5.0, 2.0, 8.0), Colour(0.9, 0.3, 0.6));
 	light1.castShadows(false);
@@ -23,15 +26,33 @@
 
 	Material mat(Colour(0.9, 0.9, 0.9));
 	mat.setSmooth(true);
-	load_ply(rt, "../models/ply/dragon/dragon_vrip.ply", &mat, Vector3(-29,29,-29), Vector3(0,-3.6,0));
+	LinearColourMap cmap(Colour(0.5, 0.0, 0.0), Colour(1.0, 1.0, 0.5));
+	//LinearColourMap cmap(Colour(1.0, 0.2, 0.0), Colour(0.3, 0.9, 0.2));
+	mat.setTexture(new CloudTexture(10, &cmap));
 
-	rt.setCamera(&cam);
-	cam.setEye(Vector3(0,0,10));
+	ifstream fin("realtime_dragon.kdtreedump");
+	if (!fin)
+	{
+		load_ply(rt, "../models/ply/dragon/dragon_vrip.ply",
+			&mat, Vector3(-29,29,-29), Vector3(0,-3.6,0));
+		top.optimize();
+	}
+	else
+		top.load(fin, &mat);
 
-	top.optimize();
+	for (int i = 1; i < argc; i++)
+	{
+		if (strcmp(argv[1], "-dump") == 0)
+		{
+			resetSerializer();
+			ofstream fout("realtime_dragon.kdtreedump");
+			fout << top << endl;
+			fout.close();
+		}
 
-	if (argc == 2 && strcmp(argv[1], "-buildonly") == 0)
-		return 0;
+		if (strcmp(argv[1], "-buildonly") == 0)
+			return 0;
+	}
 
 	loop_sdl(rt, cam);
 }