Skip to main content

Python/pyglet library for importing Wavefront .obj files

Project description

PyWavefront
===========

This python module allows you to read Wavefront 3D object files
(`something.obj` and `something.mtl`) and use them as Python objects.
If you optionally want to render and display these objects, Pyglet is required.

Currently, only a subset of [the defined
specification](https://en.wikipedia.org/wiki/Wavefront_.obj_file) has
been implemented.

Current test status: [![CircleCI](https://circleci.com/gh/greenmoss/PyWavefront.svg?style=svg)](https://circleci.com/gh/greenmoss/PyWavefront)

Slack: [channel](https://pywavefront.slack.com/)

Optional Dependencies
------------

* [Pyglet](http://www.pyglet.org/)

Usage
-----

### From Python

**Basic**

```python
import pywavefront
meshes = pywavefront.Wavefront('something.obj')
```

**Visualization**

```python
import pywavefront

[create a window and set up your OpenGl context]
meshes = pywavefront.Wavefront('something.obj')

[inside your drawing loop]
meshes.draw()
```

### Example Script

There are two pyglet example scripts with included `.obj` and `.mtl` files in the `example` directory. To run them, change to the `example`
directory and run either `./pyglet_demo.py` or `.pyglet_demo2.py`. Pyglet is required for these.

### Generating a Wavefront file with Blender

The following presumes you are using [Blender](http://www.blender.org/) 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 `*.obj` file as in the pywavefront example above.

Installation
------------

### Source distribution

Assuming you are in the top-level PyWavefront directory:

python setup.py install

### Pip

pip install PyWavefront

Tests
-----

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 this `README` file.
* Run `nosetests`

Contributors
-------

* Daniel Coelho
* dav92lee
* Einar Forselv
* Jerek Shoemaker
* Kurt Yoder
* Marxlp
* Patrik Huber
* Sérgio Agostinho
* Zohar Jackson

License
-------

PyWavefront is BSD-licensed; see file `LICENSE`.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyWavefront-0.3.0.tar.gz (12.6 kB view details)

Uploaded Source

File details

Details for the file PyWavefront-0.3.0.tar.gz.

File metadata

  • Download URL: PyWavefront-0.3.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyWavefront-0.3.0.tar.gz
Algorithm Hash digest
SHA256 38400405f6086520c3e0585d4562521f1b8868f239d4ba89ae4e00a38d043a0a
MD5 c73c1ff95325c62bbf4de2081accc7c8
BLAKE2b-256 63ec97b14c37e0cdb28b1b84b30be822577fc745f53ed74f197abce3e3b9b632

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page