This module produces functionality to read and write wavefront (.OBJ) files.
http://en.wikipedia.org/wiki/Wavefront_.obj_file
The wavefront format is quite powerful and allows a wide variety of surfaces to be described.
This implementation does only supports mesh stuff, so no nurbs etc. Further, material properties are ignored, although this might be implemented later,
The classes are written with compatibility of Python3 in mind.
vispy.io.wavefront.
WavefrontReader
Bases: object
object
finish
Converts gathere lists to numpy arrays and creates BaseMesh instance.
read
This classmethod is the entry point for reading OBJ files.
The name of the file to read.
Can be “obj” or “gz” to specify the file format.
readFace
Each face consists of three or more sets of indices. Each set consists of 1, 2 or 3 indices to vertices/normals/texcords.
readLine
The method that reads a line and processes it.
readTuple
Reads a tuple of numbers. e.g. vertices, normals or teture coords.
WavefrontWriter
write
This classmethod is the entry point for writing mesh data to OBJ.
The filename to write to. Must end with “.obj” or “.gz”.
The vertex data
The face data
The texture coordinate per vertex
The name of the object (e.g. ‘teapot’)
Reshape the faces array to (Nf, 3). Set to False if you need to write a mesh with non triangular faces.
writeFace
Write the face info to the net line.
writeLine
Simple writeLine function to write a line of code to the file. The encoding is done here, and a newline character is added.
writeMesh
Write the given mesh instance.
writeTuple
Writes a tuple of numbers (on one line).