parseUsemtl parses a "usemtl" decription line: usemtl
(fields []string)
| 667 | // parseUsemtl parses a "usemtl" decription line: |
| 668 | // usemtl <name> |
| 669 | func (dec *Decoder) parseUsemtl(fields []string) error { |
| 670 | |
| 671 | if len(fields) < 1 { |
| 672 | return dec.formatError("Usemtl with no fields") |
| 673 | } |
| 674 | |
| 675 | // NOTE(quillaja): see similar nil test in parseFace() |
| 676 | if dec.objCurrent == nil { |
| 677 | dec.parseObject([]string{fmt.Sprintf("unnamed%d", dec.line)}) |
| 678 | } |
| 679 | |
| 680 | // Checks if this material has already been parsed |
| 681 | name := fields[0] |
| 682 | mat := dec.Materials[name] |
| 683 | // Creates material descriptor |
| 684 | if mat == nil { |
| 685 | mat = new(Material) |
| 686 | mat.Name = name |
| 687 | dec.Materials[name] = mat |
| 688 | } |
| 689 | dec.objCurrent.materials = append(dec.objCurrent.materials, name) |
| 690 | // Set this as the current material |
| 691 | dec.matCurrent = mat |
| 692 | return nil |
| 693 | } |
| 694 | |
| 695 | // parseSmooth parses a "s" decription line: |
| 696 | // s <0|1> |
no test coverage detected