MCPcopy Index your code
hub / github.com/g3n/engine / parseUsemtl

Method parseUsemtl

loader/obj/obj.go:669–693  ·  view source on GitHub ↗

parseUsemtl parses a "usemtl" decription line: usemtl

(fields []string)

Source from the content-addressed store, hash-verified

667// parseUsemtl parses a "usemtl" decription line:
668// usemtl <name>
669func (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>

Callers 1

parseObjLineMethod · 0.95

Calls 2

formatErrorMethod · 0.95
parseObjectMethod · 0.95

Tested by

no test coverage detected