Parses a chunk of a 3dsmax file - this function calls itself
| 399 | #define skip(f, n) cfseek(f, n, SEEK_CUR) |
| 400 | // Parses a chunk of a 3dsmax file - this function calls itself |
| 401 | void Parse3DSMaxChunk(CFILE *fp, int size) { |
| 402 | uint16_t id; |
| 403 | int len; |
| 404 | int level = Nest_level; |
| 405 | int i; |
| 406 | float scale_factor = 0.0254f; // 0.0254 inches/meter |
| 407 | |
| 408 | Nest_level++; |
| 409 | |
| 410 | while (size && !cfeof(fp)) { |
| 411 | |
| 412 | id = cf_ReadShort(fp); |
| 413 | len = cf_ReadInt(fp); |
| 414 | |
| 415 | if (size < 0) { |
| 416 | mprintf(0, "%d:chunk error\n", level); |
| 417 | exit(1); |
| 418 | } |
| 419 | |
| 420 | switch (id) { |
| 421 | case ID_UNKNOWN: |
| 422 | Parse3DSMaxChunk(fp, len - 6); |
| 423 | break; |
| 424 | |
| 425 | case ID_MAT_NAME: { |
| 426 | char material_name[PAGENAME_LEN]; |
| 427 | |
| 428 | cf_ReadString(material_name, PAGENAME_LEN, fp); |
| 429 | |
| 430 | strcpy(Materials[Num_materials].name, material_name); |
| 431 | Num_materials++; |
| 432 | |
| 433 | ASSERT(Num_materials < MAX_MATERIALS); |
| 434 | break; |
| 435 | } |
| 436 | |
| 437 | case ID_MATERIAL: { |
| 438 | Parse3DSMaxChunk(fp, len - 6); |
| 439 | break; |
| 440 | } |
| 441 | |
| 442 | case ID_MAT_TEXTURE: { |
| 443 | int i; |
| 444 | char texture_name[PAGENAME_LEN]; |
| 445 | |
| 446 | // Read in Unknown field |
| 447 | for (i = 0; i < 6; i++) |
| 448 | cf_ReadByte(fp); |
| 449 | |
| 450 | cf_ReadShort(fp); |
| 451 | |
| 452 | // Read in Unknown field |
| 453 | for (i = 0; i < 6; i++) |
| 454 | cf_ReadByte(fp); |
| 455 | |
| 456 | cf_ReadString(texture_name, PAGENAME_LEN, fp); |
| 457 | |
| 458 | // Find the texture that has this bitmap as a name |
no test coverage detected