This module contains the OBJReader and MTLReader classes which can be used as a base class for reading Wavefront OBJ and MTL files. The classes read the files and invoke callback methods with the corresponding data in the file. Derived classes have to implement those callback methods and process the data as appropriate.
The OBJReader class reads Wavefront OBJ files and calls appropriate methods which have to be implemented in a derived class.
Creates an instance of the reader.
Read the content of a file. f must be a file like object that can be used to read the content of the file.
Callback method that is called before the file is read.
Callback method that is called after the file was read.
This method is called when a keyword is encountered that has no corresponding handler method.
The following are the predefined handler methods:
Read the content of a file. f must be a file like object that can be used to read the content of the file.
Callback method that is called before the file is read.
Callback method that is called after the file was read.
This method is called when a keyword is encountered that has no corresponding handler method.
The following are the predefined handler methods:
Start of a new material definition.
Illumination model.
Ambient color.
Diffuse color.
Specular color.
Emissive color.
Refraction index.
Transparency.
Transparency.
Transparency.
The OBJReader and MTLReader classes can also handle keywords that are not known to the classes. For each keyword, the classes look for a method called handle_<keyword> which is invoked with the arguments as parameters. If such a handler is not found, the handleUnknown() method is called.
For the standard keywords such handle_<keyword> handlers are already available. Their task is to preprocess the arguments and call the final handler method (which is just named after the keyword).