示例#1
0
int main(int argc, char ** argv){

	if(argc == 1){
	printf("usage: pgm_name file1.xy file2.xy ... \n");
	exit(1);
}
setUp();
loadFiles(argc, argv);
scaleNfit(argc);


int num;
while(1 == 1){
	num = G_wait_key();
	if( num >= 48 && num <= 57){
		num = num - 48;
		if(num < argc){
			display(num);
		}
	}
	if(num == 81 || num == 113){
		break;
	}
}
}
示例#2
0
int main(int argc, char ** argv){

	if(argc == 1){
	printf("usage: pgm_name file1.xy file2.xy ... \n");
	exit(1);
}
int specpow;
double diffusepro, ambient;
 diffusepro = .5;
 ambient = .2;
double x = -200;
double y=-100;
double z=50;
 specpow = 70;
// red = 1;
// green = 0;
// blue = 0;

// printf("enter ambeint  > ");
// scanf("%lf", &ambient);
// printf("enter Diffuse  > ");
// scanf("%lf", &diffusepro);
// printf("enter specular  > ");
// scanf("%d", &specpow);
// printf("enter light coordinates \n");
// scanf("%lf %lf %lf", &x, &y, &z);

int i = 0;
for(i=0;i< argc-1;i++){
	printf("enter object %d color \n", i);
scanf("%lf %lf %lf", &red[i], &green[i], &blue[i]);
}

setUp();
loadFiles(argc, argv);
scaleNfit(argc);
display(0, 1, specpow, diffusepro, ambient, x ,y,z);
int num, file, axis;
file = 0;
axis = 0;
int sign = 0;
int direction = 0;
while(1 == 1){
	num = G_wait_key();

	if(num == 114){
		rotate(file, axis, direction);
		resize();
		display(file, sign, specpow, diffusepro, ambient, x , y, z);
	}
	else if(num == 81 || num == 113){//quit
		break;
	}
	else if(num ==120){//x-axis
		axis = 0;
	}
	else if(num == 121){//y-axis
		axis = 1;
	}
	else if(num == 122){//z-axis 
		axis = 2;
	}
	else if(num == 116){//translate 
		translate(file, axis, direction);
		resize();
		display(file,sign, specpow, diffusepro, ambient, x , y, z);
	}
	else if(num == 99){//change translate direction
		if(direction == 0){
			direction = 1;
		}else{
			direction=0;
		}
	}else if(num == 'h'){//adjust hither
		(sign==0) ? (hither+=.1 ): (hither-=.1);
		display(file, sign, specpow, diffusepro, ambient, x , y, z);
	}
	else if( num >= 48 && num <= 57){//choose file
		file = num - 48;
		if(file < argc){
			display(file, sign, specpow, diffusepro, ambient, x , y, z);
		}
	}else if(num == 115){
		sign = (sign+1)%2;

		display(file, sign, specpow, diffusepro, ambient, x , y, z);
	}else{
		printf("no command");
	}
}
}