コード例 #1
0
ファイル: script.c プロジェクト: kasicass/frustum
static int load_land(scene_t *scene,FILE *file,char *path,int texture_mode) {
    char buffer[128];
    land_config_t config;
    memset(&config,0,sizeof(land_config_t));
    config.num_base = 1;
    config.num_detail = 1;
    config.texture_mode = texture_mode;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"land")) load_name(file,path,config.heightmap);
        else if(!strcmp(buffer,"step")) config.step = load_float(file);
        else if(!strcmp(buffer,"altitude")) config.altitude = load_float(file);
        else if(!strcmp(buffer,"lod")) config.lod = load_float(file);
        else if(!strcmp(buffer,"ambient")) load_color(file,config.ambient);
        else if(!strcmp(buffer,"diffuse")) load_color(file,config.diffuse);
        else if(!strcmp(buffer,"specular")) load_color(file,config.specular);
        else if(!strcmp(buffer,"base")) load_name(file,path,config.base);
        else if(!strcmp(buffer,"num_base")) config.num_base = load_int(file);
        else if(!strcmp(buffer,"detail")) load_name(file,path,config.detail);
        else if(!strcmp(buffer,"num_detail")) config.num_detail = load_int(file);
        else if(!strcmp(buffer,"}")) {
            scene->land = land_create(&config);
            break;
        } else return 0;
    }
    if(!scene->land) return 0;
    return 1;
}
コード例 #2
0
ファイル: script.c プロジェクト: kasicass/frustum
static int load_sky_layer(sky_config_t *config,FILE *file,char *path) {
    char buffer[128];
    int layer = 0;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"layer")) layer = load_int(file);
        else if(!strcmp(buffer,"height")) config->height[layer] = load_float(file);
        else if(!strcmp(buffer,"time")) config->time[layer] = load_float(file);
        else if(!strcmp(buffer,"texture")) load_name(file,path,config->texture[layer]);
        else if(!strcmp(buffer,"}")) break;
        else return 0;
    }
    return 1;
}
コード例 #3
0
ファイル: script.c プロジェクト: kasicass/frustum
static int load_sky_sun(scene_t *scene,FILE *file,char *path,int texture_mode) {
    char buffer[128],pathname[256];
    float length = 0;
    sky_sun_config_t config;
    memset(&config,0,sizeof(sky_sun_config_t));
    config.texture_mode = texture_mode;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"pos")) load_pos(file,config.pos);
        else if(!strcmp(buffer,"color")) load_color(file,config.color);
        else if(!strcmp(buffer,"num_flare")) config.num_flare = load_int(file);
        else if(!strcmp(buffer,"flare")) load_sky_sun_flare(&config,file,path);
        else if(!strcmp(buffer,"length")) length = load_float(file);
        else if(!strcmp(buffer,"path")) {
            load_name(file,path,pathname);
            if(length <= scene->end - scene->start)
                scene->pathsun = spline_close_load(pathname,length,0,0,0);
            else scene->pathsun = spline_load(pathname,length,0,0,0);
            if(!scene->pathsun) return 0;
        } else if(!strcmp(buffer,"}")) {
            scene->sun = sky_sun_load(&config);
            break;
        } else return 0;
    }
    if(!scene->sun) return 0;
    return 1;
}
コード例 #4
0
ファイル: script.c プロジェクト: kasicass/frustum
static int load_sky_sun_flare(sky_sun_config_t *config,FILE *file,char *path) {
    char buffer[128];
    int flare = 0;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"flare")) flare = load_int(file);
        else if(!strcmp(buffer,"position")) config->position[flare] = load_float(file);
        else if(!strcmp(buffer,"radius")) config->radius[flare] = load_float(file);
        else if(!strcmp(buffer,"opacity")) config->opacity[flare] = load_float(file);
        else if(!strcmp(buffer,"texture")) load_name(file,path,config->texture[flare]);
        else if(!strcmp(buffer,"}")) break;
        else return 0;
    }
    return 1;
}
コード例 #5
0
void test_double_float() {
    test_header();

    double d = 2.2354e-10;
    float f = d;
    uint32_t i = 7821334;
    uchar_vec b;
    unsigned char *buffer = NULL;

    kv_init(b);
    dump_double(d, &b);
    buffer = b.a;
    fprintf(stderr, "%g == %g - ", d, load_double(&buffer));
    fprintf(stderr, "buffer used: %zu\n", buffer - b.a);

    kv_clear(b);
    dump_float(f, &b);
    buffer = b.a;
    fprintf(stderr, "%g == %g - ", d, load_float(&buffer));
    fprintf(stderr, "buffer used: %zu\n", buffer - b.a);

    kv_clear(b);
    dump_uint32(i, &b);
    buffer = b.a;
    fprintf(stderr, "%d == %d - ", i, load_uint32(&buffer));
    fprintf(stderr, "buffer used: %zu\n", buffer - b.a);

    kv_destroy(b);
}
コード例 #6
0
ファイル: script.c プロジェクト: kasicass/frustum
static int load_camera(scene_t *scene,FILE *file,char *path) {
    char buffer[128],pathname[256];
    float length = 0;
    camera_config_t config;
    memset(&config,0,sizeof(camera_config_t));
    config.aspect = 4.0 / 3.0;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"start")) scene->start = load_float(file);
        else if(!strcmp(buffer,"end")) scene->end = load_float(file);
        else if(!strcmp(buffer,"length")) length = load_float(file);
        else if(!strcmp(buffer,"pathpos")) {
            load_name(file,path,pathname);
            if(length <= scene->end - scene->start) scene->pathpos = spline_close_load(pathname,length,0,0,0);
            else scene->pathpos = spline_load(pathname,length,0,0,0);
            if(!scene->pathpos) return 0;
        } else if(!strcmp(buffer,"pathdir")) {
            load_name(file,path,pathname);
            if(length <= scene->end - scene->start) scene->pathdir = spline_close_load(pathname,length,0,0,0);
            else scene->pathdir = spline_load(pathname,length,0,0,0);
            if(!scene->pathdir) return 0;
        } else if(!strcmp(buffer,"fov")) config.fov = load_float(file);
        else if(!strcmp(buffer,"aspect")) config.aspect = load_float(file);
        else if(!strcmp(buffer,"clipnear")) config.clipnear = load_float(file);
        else if(!strcmp(buffer,"clipfar")) config.clipfar = load_float(file);
        else if(!strcmp(buffer,"fogcolor")) load_color(file,config.fogcolor);
        else if(!strcmp(buffer,"fogstart")) config.fogstart = load_float(file);
        else if(!strcmp(buffer,"fogend")) config.fogend = load_float(file);
        else if(!strcmp(buffer,"}")) {
            scene->camera = camera_create(&config);
            break;
        } else return 0;
    }
    if(!scene->camera) return 0;
    return 1;
}
コード例 #7
0
ファイル: script.c プロジェクト: kasicass/frustum
static int load_sky(scene_t *scene,FILE *file,char *path,int texture_mode) {
    char buffer[128];
    sky_config_t config;
    memset(&config,0,sizeof(sky_config_t));
    config.texture_mode = texture_mode;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"mesh")) load_name(file,path,config.mesh);
        else if(!strcmp(buffer,"num_layer")) config.num_layer = load_int(file);
        else if(!strcmp(buffer,"target")) config.target = load_float(file);
        else if(!strcmp(buffer,"layer")) load_sky_layer(&config,file,path);
        else if(!strcmp(buffer,"sun")) {
            if(!load_sky_sun(scene,file,path,texture_mode)) return 0;
        } else if(!strcmp(buffer,"}")) {
            scene->sky = sky_load(&config);
            break;
        } else return 0;
    }
    if(!scene->sky) return 0;
    return 1;
}
コード例 #8
0
ファイル: macsim_fmt.c プロジェクト: deweerdt/TSP
/*read the data contain in the file
*/
int32_t macsim_read(GenericReader_T* genreader,glu_item_t* item)
{
	char  	      data_var[LG_MAX_STRING_MACSIM];
	uint32_t      indice_data=0,
	              rep=EOF,
	              dimension=0;
	uint8_t       continuer=1;
	

	TSP_sample_symbol_info_list_t  ssi_list;

	ssi_list=*genreader->ssi_list;

	
	if(NULL!=genreader->handler->file)
	{

	  /*TYPE_CHAR or TYPE_UCHAR is a  string of  LG_MAX_STRING_MACSIM length */
	  if( (TSP_TYPE_CHAR==ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type)
	      || (TSP_TYPE_UCHAR==ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type) )
	  {
	    item->size=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension;
	    /*calculate the real dimension for the string symbol*/
	    dimension=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension/LG_MAX_STRING_MACSIM;
	  }
	  else
	  {
	    item->size=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension;
	    dimension=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension;
	      
	  }
	  
	  item->size*=tsp_type_size[ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type];

	    
	  while( continuer  && 
                (indice_data<dimension))
	  {

	    memset(data_var,'\0',LG_MAX_STRING_MACSIM);

	    /*read one data of the file*/
	    rep=read_data_file(genreader->handler->file,data_var);
              
	    if(EOF!=rep)
	    {
	      /*end of line*/
	      if(END_SAMPLE_SET==rep)
	      {
		continuer=0;
	      }

	      /*load retrieve data in the raw value*/
	      switch(ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type) 
	      {

	        case TSP_TYPE_DOUBLE :
		  load_double(data_var,item->raw_value,indice_data);
		  break;
				       
	        case TSP_TYPE_FLOAT :
		  load_float(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_INT8 :
		  load_int8(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_INT16:
		  load_int16(data_var,item->raw_value,indice_data);
		  break;

	        case TSP_TYPE_INT32 :
		  load_int32(data_var,item->raw_value,indice_data);
		  break;
      
	        case TSP_TYPE_INT64 :
		  load_int64(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT8:
		  load_uint8(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT16:
		  load_uint16(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT32:
		  load_uint32(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT64:
		  load_uint64(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_CHAR:
		  load_char(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UCHAR:
		  load_uchar(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_RAW:
		  load_type_raw(data_var,item->raw_value,indice_data);
		  break;
    
	        default:
		  break;
	      }

	      ++indice_data;
	    
	    }
	    else
	    {
	      continuer=0;
	    }

	  }
   
	}
         return(rep);
}