parameters: (materials, mtlfilename, basename)
return_statement: return mtl
docstring: Parse MTL file and create mapping between its materials and OBJ materials.
         Eventual edge cases are handled here (missing materials, missing MTL file).
docstring_summary: Parse MTL file and create mapping between its materials and OBJ materials.
         Eventual edge cases are handled here (missing materials, missing MTL file).
docstring_tokens: Parse MTL file and create mapping between its materials and OBJ materials . Eventual edge cases are handled here ( missing materials missing MTL file ) .
function: def create_materials(materials, mtlfilename, basename):
      """Parse MTL file and create mapping between its materials and OBJ materials.
         Eventual edge cases are handled here (missing materials, missing MTL file).
      """
  
      random.seed(42) # to get well defined color order for debug colors
  
      # default materials with debug colors for when
      # there is no specified MTL / MTL loading failed,
      # or if there were no materials / null materials
  
      mtl = generate_mtl(materials)
  
      if mtlfilename:
  
          # create full pathname for MTL (included from OBJ)
  
          path = os.path.dirname(basename)
          fname = os.path.join(path, mtlfilename)
  
          if file_exists(fname):
  
              # override default materials with real ones from MTL
              # (where they exist, otherwise keep defaults)
  
              mtl.update(parse_mtl(fname))
  
          else:
  
              print "Couldn't find [%s]" % fname
  
      return mtl
function_tokens: def create_materials ( materials , mtlfilename , basename ) : random . seed ( 42 ) # to get well defined color order for debug colors # default materials with debug colors for when # there is no specified MTL / MTL loading failed, # or if there were no materials / null materials mtl = generate_mtl ( materials ) if mtlfilename : # create full pathname for MTL (included from OBJ) path = os . path . dirname ( basename ) fname = os . path . join ( path , mtlfilename ) if file_exists ( fname ) : # override default materials with real ones from MTL # (where they exist, otherwise keep defaults) mtl . update ( parse_mtl ( fname ) ) else : print "Couldn't find [%s]" % fname return mtl