static Lib3dsBool mdata_read(Lib3dsFile *file, FILE *f) { Lib3dsChunk c; Lib3dsWord chunk; if (!lib3ds_chunk_read_start(&c, LIB3DS_MDATA, f)) { return(LIB3DS_FALSE); } while ((chunk=lib3ds_chunk_read_next(&c, f))!=0) { switch (chunk) { case LIB3DS_MESH_VERSION: { file->mesh_version=lib3ds_intd_read(f); } break; case LIB3DS_MASTER_SCALE: { file->master_scale=lib3ds_float_read(f); } break; case LIB3DS_SHADOW_MAP_SIZE: case LIB3DS_LO_SHADOW_BIAS: case LIB3DS_HI_SHADOW_BIAS: case LIB3DS_SHADOW_SAMPLES: case LIB3DS_SHADOW_RANGE: case LIB3DS_SHADOW_FILTER: case LIB3DS_RAY_BIAS: { lib3ds_chunk_read_reset(&c, f); if (!lib3ds_shadow_read(&file->shadow, f)) { return(LIB3DS_FALSE); } } break; case LIB3DS_VIEWPORT_LAYOUT: case LIB3DS_DEFAULT_VIEW: { lib3ds_chunk_read_reset(&c, f); if (!lib3ds_viewport_read(&file->viewport, f)) { return(LIB3DS_FALSE); } } break; case LIB3DS_O_CONSTS: { int i; for (i=0; i<3; ++i) { file->construction_plane[i]=lib3ds_float_read(f); } } break; case LIB3DS_AMBIENT_LIGHT: { lib3ds_chunk_read_reset(&c, f); if (!ambient_read(file, f)) { return(LIB3DS_FALSE); } } break; case LIB3DS_BIT_MAP: case LIB3DS_SOLID_BGND: case LIB3DS_V_GRADIENT: case LIB3DS_USE_BIT_MAP: case LIB3DS_USE_SOLID_BGND: case LIB3DS_USE_V_GRADIENT: { lib3ds_chunk_read_reset(&c, f); if (!lib3ds_background_read(&file->background, f)) { return(LIB3DS_FALSE); } } break; case LIB3DS_FOG: case LIB3DS_LAYER_FOG: case LIB3DS_DISTANCE_CUE: case LIB3DS_USE_FOG: case LIB3DS_USE_LAYER_FOG: case LIB3DS_USE_DISTANCE_CUE: { lib3ds_chunk_read_reset(&c, f); if (!lib3ds_atmosphere_read(&file->atmosphere, f)) { return(LIB3DS_FALSE); } } break; case LIB3DS_MAT_ENTRY: { Lib3dsMaterial *material; material=lib3ds_material_new(); if (!material) { return(LIB3DS_FALSE); } lib3ds_chunk_read_reset(&c, f); if (!lib3ds_material_read(material, f)) { return(LIB3DS_FALSE); } lib3ds_file_insert_material(file, material); } break; case LIB3DS_NAMED_OBJECT: { lib3ds_chunk_read_reset(&c, f); if (!named_object_read(file, f)) { return(LIB3DS_FALSE); } } break; default: lib3ds_chunk_unknown(chunk); } } lib3ds_chunk_read_end(&c, f); return(LIB3DS_TRUE); }
static void mdata_read(Lib3dsFile *file, Lib3dsIo *io) { Lib3dsChunk c; uint16_t chunk; lib3ds_chunk_read_start(&c, CHK_MDATA, io); while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) { switch (chunk) { case CHK_MESH_VERSION: { file->mesh_version = lib3ds_io_read_intd(io); break; } case CHK_MASTER_SCALE: { file->master_scale = lib3ds_io_read_float(io); break; } case CHK_SHADOW_MAP_SIZE: case CHK_LO_SHADOW_BIAS: case CHK_HI_SHADOW_BIAS: case CHK_SHADOW_SAMPLES: case CHK_SHADOW_RANGE: case CHK_SHADOW_FILTER: case CHK_RAY_BIAS: { lib3ds_chunk_read_reset(&c, io); lib3ds_shadow_read(&file->shadow, io); break; } case CHK_VIEWPORT_LAYOUT: case CHK_DEFAULT_VIEW: { lib3ds_chunk_read_reset(&c, io); lib3ds_viewport_read(&file->viewport, io); break; } case CHK_O_CONSTS: { int i; for (i = 0; i < 3; ++i) { file->construction_plane[i] = lib3ds_io_read_float(io); } break; } case CHK_AMBIENT_LIGHT: { lib3ds_chunk_read_reset(&c, io); ambient_read(file, io); break; } case CHK_BIT_MAP: case CHK_SOLID_BGND: case CHK_V_GRADIENT: case CHK_USE_BIT_MAP: case CHK_USE_SOLID_BGND: case CHK_USE_V_GRADIENT: { lib3ds_chunk_read_reset(&c, io); lib3ds_background_read(&file->background, io); break; } case CHK_FOG: case CHK_LAYER_FOG: case CHK_DISTANCE_CUE: case CHK_USE_FOG: case CHK_USE_LAYER_FOG: case CHK_USE_DISTANCE_CUE: { lib3ds_chunk_read_reset(&c, io); lib3ds_atmosphere_read(&file->atmosphere, io); break; } case CHK_MAT_ENTRY: { Lib3dsMaterial *material = lib3ds_material_new(NULL); lib3ds_file_insert_material(file, material, -1); lib3ds_chunk_read_reset(&c, io); lib3ds_material_read(material, io); break; } case CHK_NAMED_OBJECT: { lib3ds_chunk_read_reset(&c, io); named_object_read(file, io); break; } default: lib3ds_chunk_unknown(chunk, io); } } lib3ds_chunk_read_end(&c, io); }