示例#1
0
int height_calculation_main(int argc, char* argv[]){
	long duration;
	int cm;
	
	if(argc == 2){
		duration = atoi(argv[1]);
		cm = duration_to_cm(duration);
		PRINT;
		printf("CM: %d", cm);
		PRINT;
		int action;
		action = height_filter(cm);
		switch(action){
			case UP:
				printf("Me go UP :)");
				break;
			case DOWN:
				printf("Me go DOWN :)");
				break;
			case HOVER:
				printf("Me do nothing, me just HOVER :)");
				break;
			case CRASH:
				printf("Me CRASH :'(");
				break;
			default:
				printf("Me donno what to do '?.?'");
		}
		PRINT;		
	}
	else printf("Enter the distance!");
}
示例#2
0
void surface_height::height_filter(MID_POINT_CONFIG *p_config,
                                   int x, int y,
                                   float h0, float h1, float h2, float h3,
                                   SQUARE_TYPE type,
                                   SQUARE_INTERPOLATION_TYPE itype,
                                   float iteration,
                                   bool generate)
{ 
  height_filter(x,y,surface_height_filter_interpolate2,FALSE);
}
示例#3
0
void surface_height::height_filter(tpos x, tpos y,
                                   tpos width, tpos height,
                                   FILTER_KERNEL_FUNC *p_kernel,
                                   bool center)
{  
  if(rect_trim(x, y, width, height)) {
    int sx,sy;
    for(sy = 0; sy < height; sy++) {
      for(sx = 0; sx < width; sx++) {
        height_filter(sx+x,sy+y,p_kernel,center);
      }
    }
  }
}
示例#4
0
void surface_height::height_fill(tpos x, tpos y,
                                 tpos width, tpos height,
                                 FILTER_KERNEL_FUNC *p_kernel)
{
  if(rect_trim(x, y, width, height)) {  
    int sx,sy;
    for(sy = 0; sy < height; sy++) {
      for(sx = 0; sx < width; sx++) {
        
        tpos cx = sx + x;
        tpos cy = sy + y;
        
        if(height_get(cx,cy) == HEIGHT_UNSET) {        
          height_filter(cx,cy,p_kernel);
        }
      }
    }
  }
}
示例#5
0
void surface_height::generate_mid_point(MID_POINT_CONFIG *p_config,
                                        int x, int y, int width, int height)
{
  fill(x, y, width, height, HEIGHT_UNSET);
  
  // Generate the heightmap
  p_config->height_overwrite = FALSE;
  int j;
  for(j = 0; ; j++) {
    p_config->iteration_target = j;
    if(!height_rectangle_emit(p_config, x, y, width-1, height-1, 0,
                              SQUARE_TYPE_1, &surface_height::height_write))
      break;
  }

  // Filter back some patterns, if required
  if(p_config->pixel_filter_back) {
    p_config->height_overwrite = TRUE;
    for(j = 0; ; j++) {
      p_config->iteration_target = j;
      if(!height_rectangle_emit(p_config, x, y, width-1, height-1, 0,
                                SQUARE_TYPE_1, &surface_height::height_filter))
        break;
    }
  }

  // Fill missing pixels
  if(p_config->pixel_fill) {
    height_fill(x, y, width, height, surface_height_filter_interpolate2);
  }
  
  // Filter
  if(p_config->pixel_filter) {
    int i;
    for(i = 0; i < p_config->pixel_filter_num; i++) {
      height_filter(x, y, width, height, surface_height_filter_interpolate2);
    }
  }
  
  // Normalize the result
  height_normalize(x, y, width, height);
}