Skip to content

Commit 2e41521

Browse files
author
Kurt Yoder
authored
Merge pull request #48 from einarf/readme
README revamp suggestion
2 parents c9202ca + 0bd0193 commit 2e41521

File tree

1 file changed

+65
-39
lines changed

1 file changed

+65
-39
lines changed

README.md

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,87 @@
1+
![pypi](https://img.shields.io/pypi/v/PyWavefront.svg)
2+
[![CircleCI](https://circleci.com/gh/greenmoss/PyWavefront.svg?style=svg)](https://circleci.com/gh/greenmoss/PyWavefront)
3+
14
PyWavefront
25
===========
36

4-
This python module allows you to read Wavefront 3D object files
5-
(`something.obj` and `something.mtl`) and use them as Python objects.
6-
If you optionally want to render and display these objects, Pyglet is required.
7+
PyWavefront reads Wavefront 3D object files (`something.obj` and `something.mtl`)
8+
and generates interleaved vertex data for each material ready for rendering.
9+
Python 2.7.x or 3.6+ is supported. A simple (optional) visualization module is also
10+
provided for rendering the object(s). The interleaved data can also be used by
11+
more modern renderers thought VBOs or VAOs.
712

8-
Currently, only a subset of [the defined
9-
specification](https://en.wikipedia.org/wiki/Wavefront_.obj_file) has
10-
been implemented.
13+
Currently the most commonly used features in [the defined specification](https://en.wikipedia.org/wiki/Wavefront_.obj_file) has
14+
been implemented. Positions, texture coordinates, normals, vertex color and material parsing.
15+
We currently don't support parameter space vertices, line elements or smoothing groups.
16+
Create an issue or pull request on github if needed features are missing.
1117

12-
Current test status: [![CircleCI](https://circleci.com/gh/greenmoss/PyWavefront.svg?style=svg)](https://circleci.com/gh/greenmoss/PyWavefront)
18+
The package is on pypi or can be cloned on [github](https://github.com/greenmoss/PyWavefront).
1319

14-
Slack: [channel](https://pywavefront.slack.com/)
20+
```
21+
pip install PyWavefront
22+
```
1523

16-
Optional Dependencies
17-
------------
24+
## Usage
1825

19-
* [Pyglet](http://www.pyglet.org/)
26+
Basic example loading and obj file:
2027

21-
Usage
22-
-----
28+
```python
29+
import pywavefront
30+
scene = pywavefront.Wavefront('something.obj')
31+
```
2332

24-
### From Python
33+
A more complex example
2534

26-
**Basic**
35+
* `strict` will raise an exception if unsupported features are found in the obj or mtl file. Default `True`.
36+
* `encoding` of the obj and mtl file(s). Default `utf-8`.
37+
* `parse` decides if parsing should start immediately. Default 'False'.
2738

2839
```python
2940
import pywavefront
30-
meshes = pywavefront.Wavefront('something.obj')
41+
scene = pywavefront.Wavefront('something.obj', strict=True, encoding="iso-8859-1", parse=False)
42+
scene.parse() # Explicit call to parse() needed when parse=False
43+
44+
# All vertex data if merged
45+
for name, material in data.materials.items():
46+
# Contains the vertex format (string) such as "T2F_N3F_V3F"
47+
# T2F, C3F, N3F and V3F may appear in this string
48+
material.vertex_format
49+
# Contains the vertex list of floats in the format described above
50+
material.vertices
51+
# Material properties
52+
material.diffuse
53+
material.ambient
54+
material.texture
55+
# ..
56+
```
57+
58+
## Visualization
59+
60+
[Pyglet](http://www.pyglet.org/) is required to use the visualization module.
61+
```
62+
pip install pyglet
3163
```
3264

33-
**Visualization**
65+
Example:
3466

3567
```python
3668
import pywavefront
69+
from pywavefront import visualization
3770

3871
[create a window and set up your OpenGl context]
39-
meshes = pywavefront.Wavefront('something.obj')
72+
obj = pywavefront.Wavefront('something.obj')
4073

4174
[inside your drawing loop]
42-
meshes.draw()
75+
visualization.draw(obj)
4376
```
4477

45-
### Example Script
78+
### Example Scripts
4679

47-
There are two pyglet example scripts with included `.obj` and `.mtl` files in the `example` directory. To run them, change to the `example`
48-
directory and run either `./pyglet_demo.py` or `.pyglet_demo2.py`. Pyglet is required for these.
80+
The `example` directory contains some basic examples using the `visualization` module
81+
82+
* `pyglet_demo.py` : Simple textured globe
83+
* `pyglet_demo2.py` : Higher resolution textured globe
84+
* `pyglet_demo_boxes.py` : Boxes demonstrating supported vertex formats
4985

5086
### Generating a Wavefront file with Blender
5187

@@ -55,30 +91,20 @@ The following presumes you are using [Blender](http://www.blender.org/) to gener
5591
* Export the mesh from Blender using the Wavefront format, including normals.
5692
* Reference your `*.obj` file as in the pywavefront example above.
5793

58-
Installation
59-
------------
60-
61-
### Source distribution
62-
63-
Assuming you are in the top-level PyWavefront directory:
64-
65-
python setup.py install
66-
67-
### Pip
68-
69-
pip install PyWavefront
70-
71-
Tests
72-
-----
94+
## Tests
7395

7496
All tests can be found in the `test` directory. To run the tests:
7597

7698
* Install nose: `pip install nose`
7799
* Change to the top-level directory, e.g. `PyWavefront`, the directory that contains this `README` file.
78100
* Run `nosetests`
79101

80-
Contributors
81-
-------
102+
## Community
103+
104+
Slack: [channel](https://pywavefront.slack.com/). [Email the admins](mailto:pywavefront+slack@gmail.com?subject=Please%20send%20me%20an%20invitation%20to%20the%20PyWavefront%20Slack%20channel&body=Thanks!)
105+
to request an invitation. Ensure you leave the subject line intact!
106+
107+
## Contributors
82108

83109
* Daniel Coelho
84110
* dav92lee

0 commit comments

Comments
 (0)