(materials, mtlfilename, basename)
return mtl
Parse MTL file and create mapping between its materials and OBJ materials.
       Eventual edge cases are handled here (missing materials, missing MTL file).
Parse MTL file and create mapping between its materials and OBJ materials.
       Eventual edge cases are handled here (missing materials, missing MTL file).
Parse MTL file and create mapping between its materials and OBJ materials . Eventual edge cases are handled here ( missing materials missing MTL file ) .
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
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