Parses obj file line, dispatching to specific parsers
(line string)
| 425 | |
| 426 | // Parses obj file line, dispatching to specific parsers |
| 427 | func (dec *Decoder) parseObjLine(line string) error { |
| 428 | |
| 429 | // Ignore empty lines |
| 430 | fields := strings.Fields(line) |
| 431 | if len(fields) == 0 { |
| 432 | return nil |
| 433 | } |
| 434 | // Ignore comment lines |
| 435 | ltype := fields[0] |
| 436 | if strings.HasPrefix(ltype, "#") { |
| 437 | return nil |
| 438 | } |
| 439 | switch ltype { |
| 440 | // Material library |
| 441 | case "mtllib": |
| 442 | return dec.parseMatlib(fields[1:]) |
| 443 | // Object name |
| 444 | case "o": |
| 445 | return dec.parseObject(fields[1:]) |
| 446 | // Group names. We are considering "group" the same as "object" |
| 447 | // This may not be right |
| 448 | case "g": |
| 449 | return dec.parseObject(fields[1:]) |
| 450 | // Vertex coordinate |
| 451 | case "v": |
| 452 | return dec.parseVertex(fields[1:]) |
| 453 | // Vertex normal coordinate |
| 454 | case "vn": |
| 455 | return dec.parseNormal(fields[1:]) |
| 456 | // Vertex texture coordinate |
| 457 | case "vt": |
| 458 | return dec.parseTex(fields[1:]) |
| 459 | // Face vertex |
| 460 | case "f": |
| 461 | return dec.parseFace(fields[1:]) |
| 462 | // Use material |
| 463 | case "usemtl": |
| 464 | return dec.parseUsemtl(fields[1:]) |
| 465 | // Smooth |
| 466 | case "s": |
| 467 | return dec.parseSmooth(fields[1:]) |
| 468 | default: |
| 469 | dec.appendWarn(objType, "field not supported: "+ltype) |
| 470 | } |
| 471 | return nil |
| 472 | } |
| 473 | |
| 474 | // Parses a mtllib line: |
| 475 | // mtllib <name> |
nothing calls this directly
no test coverage detected