ccdemos/realtime_bunny.cc
branchpyrit
changeset 36 b490093b0ac3
parent 35 fb170fccb19f
child 37 5f954c0d34fc
equal deleted inserted replaced
35:fb170fccb19f 36:b490093b0ac3
    28 	// read header
    28 	// read header
    29 	int vertex_num, face_num;
    29 	int vertex_num, face_num;
    30 	while (token != "end_header")
    30 	while (token != "end_header")
    31 	{
    31 	{
    32 		f >> token;
    32 		f >> token;
    33 		cout << token << endl;
       
    34 		if (token == "element")
    33 		if (token == "element")
    35 		{
    34 		{
    36 			f >> token;
    35 			f >> token;
    37 			if (token == "vertex")
    36 			if (token == "vertex")
    38 				f >> vertex_num;
    37 				f >> vertex_num;
   144 
   143 
   145 	/* initialize raytracer and prepare scene */
   144 	/* initialize raytracer and prepare scene */
   146 	render_buffer = (Float *) malloc(w*h*3*sizeof(Float));
   145 	render_buffer = (Float *) malloc(w*h*3*sizeof(Float));
   147 
   146 
   148 	rt.setThreads(2);
   147 	rt.setThreads(2);
   149 	rt.setMaxDepth(3);
   148 	rt.setMaxDepth(0);
   150 
   149 
   151 	Octree top;
   150 	Octree top;
   152 	rt.setTop(&top);
   151 	rt.setTop(&top);
   153 
   152 
   154 	Light light1(Vector3(-5.0, 2.0, 8.0), Colour(0.9, 0.3, 0.6));
   153 	Light light1(Vector3(-5.0, 2.0, 8.0), Colour(0.9, 0.3, 0.6));
   158 	//Light light2(Vector3(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3));
   157 	//Light light2(Vector3(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3));
   159 	//light2.castShadows(false);
   158 	//light2.castShadows(false);
   160 	//rt.addlight(&light2);
   159 	//rt.addlight(&light2);
   161 
   160 
   162 	Material mat(Colour(0.9, 0.9, 0.9));
   161 	Material mat(Colour(0.9, 0.9, 0.9));
   163 	load_ply("../models/bunny/bun_zipper_res4.ply", &mat, 29);
   162 	load_ply("../models/bunny/bun_zipper.ply", &mat, 29);
   164 
   163 
   165 	rt.setCamera(&cam);
   164 	rt.setCamera(&cam);
   166 	cam.setEye(Vector3(0,0,10));
   165 	cam.setEye(Vector3(0,0,10));
   167 
   166 
   168 	/* build kd-tree */
   167 	/* build kd-tree */
   169 	top.setMaxDepth(3);
   168 	top.setMaxDepth(8);
   170 	top.optimize();
   169 	top.optimize();
   171 
   170 
   172 	/* loop... */
   171 	/* loop... */
   173 	SDL_Event event;
   172 	SDL_Event event;
   174 	bool quit = false;
   173 	bool quit = false;