int main( int argc, char **argv )
{
	//printf("%d\n",win_width);
	//printf("%d\n",win_height);
	// Parse the arguments
	if (argc < 2) {
		printf("Missing arguments ... use:\n");
		return -1;
	}

	set_up_chess();
	step_max = atoi(argv[1]); // maximum level of recursions

	// Optional arguments
	for(int i = 2; i < argc; i++)
	{
		if (strcmp(argv[i], "+s") == 0)	shadow_on = 1;
		else if (strcmp(argv[i], "+l")==0) reflect_on = 1;
		else if (strcmp(argv[i], "+c")==0) board_on = 1;
		else if (strcmp(argv[i], "+r")==0) refract_on = 1;
		else if (strcmp(argv[i], "+p")==0) antialias_on = 1;
		else if (strcmp(argv[i], "+f")==0) diffuse_reflection_on = 1;
	}
	if(board_on) {
		pl.height = -3;
		pl.reflectance = 0.4;
		pl.mat_ambient = vec3(0, 0, 0);
		pl.mat_diffuse1 = vec3(4, 4, 4);
		pl.mat_diffuse2 = vec3(0.0, 0.0, 0.0);
		pl.mat_specular = vec3(1.0, 1.0, 1.0);
		pl.shineness = 10;
		
	}

	//
	// ray trace the scene now
	//
	// we have used so many global variables and this function is
	// happy to carry no parameters
	//
	printf("Rendering scene using my fantastic ray tracer ...\n");
	ray_trace();
	printf("ray tracing ended\n");

	// we want to make sure that intensity values are normalized
	histogram_normalization();

	// Show the result in glut via texture mapping
	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE );
	glutInitWindowSize( WIN_WIDTH, WIN_HEIGHT );
	glutCreateWindow( "Ray tracing" );
	glewInit();
	init();

	glutDisplayFunc( display );
	glutKeyboardFunc( keyboard );
	glutMainLoop();
	return 0;
}
示例#2
0
int main( int argc, char **argv )
{
	// Parse the arguments
	if (argc < 3) {
		printf("Missing arguments ... use:\n");
		printf("./raycast [-u | -d] step_max <options>\n");
		return -1;
	}
	
	if (strcmp(argv[1], "-u") == 0) {  // user defined scene
		set_up_user_scene();
	} else { // default scene
		set_up_default_scene();
	}

	step_max = atoi(argv[2]); // maximum level of recursions

	// Optional arguments
	for(int i = 3; i < argc; i++)
	{
		if (strcmp(argv[i], "+s") == 0)	shadow_on = 1;
		if (strcmp(argv[i], "+l") == 0) reflection_on = 1;
		if (strcmp(argv[i], "+c") == 0) plane_on = 1;
		if (strcmp(argv[i], "+r") == 0) refraction_on = 1;
		if (strcmp(argv[i], "+f") == 0) stochastic_ref_on = 1;
		if (strcmp(argv[i], "+p") == 0) supersamp_on = 1;
	}

	//
	// ray trace the scene now
	//
	// we have used so many global variables and this function is
	// happy to carry no parameters
	//
	srand (time(NULL));
	printf("Rendering scene using my fantastic ray tracer ...\n");
	ray_trace();
	std::cout<<"Rays Fired:"<<raysShot<<std::endl<<"Rays Hit:"<<raysHit<<std::endl;

	// we want to make sure that intensity values are normalized
	histogram_normalization();

	// Show the result in glut via texture mapping
	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE );
	glutInitWindowSize( WIN_WIDTH, WIN_HEIGHT );
	glutCreateWindow( "Ray tracing" );
	glewInit();
	init();

	glutDisplayFunc( display );
	glutKeyboardFunc( keyboard );
	glutMainLoop();
	return 0;
}
示例#3
0
int main( int argc, char **argv )
{
	// Parse the arguments
	if (argc < 2) {
		printf("Missing arguments ... use:\n");
		printf("./raycast step_max <options>\n");
		return -1;
	}
	
	/*
	if (strcmp(argv[1], "-u") == 0) {  // user defined scene
		set_up_user_scene();
	} else { // default scene
		set_up_default_scene();
	}
	*/

	step_max = atoi(argv[1]); // maximum level of recursions

	// Optional arguments
	for(int i = 2; i < argc; i++)
	{
		if (strcmp(argv[i], "+s") == 0)	shadow_on = 1;
		if (strcmp(argv[i], "+l") == 0) reflect_on = 1;
		//if (strcmp(argv[i], "+c") == 0) chessboard_on = 1;
		if (strcmp(argv[i], "+r") == 0) refract_on = 1;
		if (strcmp(argv[i], "+f") == 0) difref_on = 1;
		if (strcmp(argv[i], "+p") == 0) antiAlias_on = 1;
		if (strcmp(argv[i], "+t") == 0) triangle_on = 1;
	}

	set_up_global_variable();

	if(chessboard_on = 1)
		set_up_chessboard();

	if(triangle_on)
		set_up_triangles();


	//printf("object Count : %d\n",objectCount);

	set_up_chessPiece();



	//printObjects();

	// ray trace the scene now
	// we have used so many global variables and this function is
	// happy to carry no parameters	
	printf("Rendering scene using my fantastic ray tracer ...\n");
	ray_trace();
	printf("After ray trace\n");

	// we want to make sure that intensity values are normalized
	histogram_normalization();

	// Show the result in glut via texture mapping
	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE );
	glutInitWindowSize( WIN_WIDTH, WIN_HEIGHT );
	glutCreateWindow( "Ray tracing" );
	glewInit();

	#ifndef __NO_DISPLAY__
	init();
	#endif
	printf("After init\n");

	glutDisplayFunc( display );
	glutKeyboardFunc( keyboard );
	glutMainLoop();

	return 0;
}