psychopy.tools.gltools.loadMtlFile

psychopy.tools.gltools.loadMtlFile(mtllib, texParams=None)[source]

Load a material library file (*.mtl).

Parameters:
  • mtllib (str) – Path to the material library file.

  • texParams (list or tuple) – Optional texture parameters for loaded textures. Texture parameters are specified as a list of tuples. Each item specifies the option and parameter. For instance, [(GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR), …]. By default, linear filtering is used for both the minifying and magnification filter functions. This is adequate for most uses.

Returns:

Dictionary of materials. Where each key is the material name found in the file, and values are Material namedtuple objects.

Return type:

dict

See also

loadObjFile

Load an *.OBJ file.

Examples

Load material associated with an *.OBJ file:

objModel = loadObjFile('/path/to/file.obj')
# load the material (*.mtl) file, textures are also loaded
mtllib = loadMtl('/path/to/' + objModel.mtlFile)

Use a material when rendering vertex arrays:

useMaterial(mtllib[material])
drawVAO(vao)
useMaterial(None)  # disable materials when done

Back to top