This python module allows you to read Wavefront 3D object files
(something.obj and something.mtl) and use them as Python objects.
Currently Pyglet is required to render and display these objects.
Currently, only a subset of the defined specification has been implemented.
import pywavefront
meshes = pywavefront.Wavefront('something.obj')
meshes.draw()
A pyglet example script with included .obj and .mtl files is
included in the example directory. To run it, change to the example
directory and run ./pyglet_demo.py.
The following presumes you are using Blender to generate your mesh:
- Using Blender, create a mesh with a UV-mapped texture. The UV-mapping is important! If it is working properly, you will see the texture applied within Blender's 3d view.
- Export the mesh from Blender using the Wavefront format, including normals.
- Reference your
*.objfile as in the pywavefront example above.
Assuming you are in the top-level PyWavefront directory:
python setup.py install
pip install PyWavefront
All tests can be found in the test directory. To run the tests:
- Install nose:
pip install nose - Change to the top-level directory, e.g.
PyWavefront, the directory that contains thisREADMEfile. - Run
nosetests
- Add material setters.
- Add lighting in example.
- Initial release.
PyWavefront is BSD-licensed; see file LICENSE.