ccdemos/realtime_dragon.cc
branchpyrit
changeset 38 5d043eeb09d9
parent 36 b490093b0ac3
child 39 7079dcc3bd74
--- a/ccdemos/realtime_dragon.cc	Fri Dec 14 00:05:54 2007 +0100
+++ b/ccdemos/realtime_dragon.cc	Fri Dec 14 10:34:31 2007 +0100
@@ -1,7 +1,7 @@
 #include <SDL.h>
 
 #include "raytracer.h"
-#include "kdtree.h"
+#include "octree.h"
 #include <iostream>
 #include <fstream>
 
@@ -41,8 +41,7 @@
 
 	// read vertices
 	Vector3 P;
-	int num = vertex_num;
-	while (num--)
+	for (int i = 0; i < vertex_num; i++)
 	{
 		f >> P.x >> P.y >> P.z;
 		P.x = -scale*P.x;
@@ -56,7 +55,7 @@
 	// read faces
 	Triangle *face;
 	int v1, v2, v3;
-	while (face_num--)
+	for (int i = 0; i < face_num; i++)
 	{
 		f >> num;
 		if (num != 3)
@@ -77,7 +76,7 @@
 		vertex_face_num.at(v3)++;
 	}
 
-	for (int i; i < vertex_num; i++)
+	for (int i = 0; i < vertex_num; i++)
 	{
 		normals.at(i) /= vertex_face_num.at(i);
 		normals.at(i).normalize();
@@ -140,10 +139,10 @@
 	/* initialize raytracer and prepare scene */
 	render_buffer = (Float *) malloc(w*h*3*sizeof(Float));
 
-	rt.setThreads(1);
-	rt.setMaxDepth(3);
+	rt.setThreads(2);
+	rt.setMaxDepth(0);
 
-	KdTree top;
+	Octree top;
 	rt.setTop(&top);
 
 	Light light1(Vector3(-5.0, 2.0, 8.0), Colour(0.9, 0.3, 0.6));
@@ -155,13 +154,11 @@
 	//rt.addlight(&light2);
 
 	Material mat(Colour(0.9, 0.9, 0.9));
-	load_ply("../models/dragon/dragon_vrip_res4.ply", &mat, 29);
+	load_ply("../models/dragon/dragon_vrip.ply", &mat, 29);
 
 	rt.setCamera(&cam);
 	cam.setEye(Vector3(0,0,10));
 
-	/* build kd-tree */
-	top.setMaxDepth(30);
 	top.optimize();
 
 	/* loop... */