Skip to main content

Occasional fork of tinyobjloader

Project description

tinyobjloader, Wavefront .obj loader

tinyobjloader is a python wrapper for C++ wavefront .obj loader. tinyobjloader is rather fast and feature rich than other pure python version of .obj loader.

Install

You can install tinyobjloader with pip.

$ pip install tinyobjloader

Quick tutorial

import sys
import tinyobjloader

# Create reader.
reader = tinyobjloader.ObjReader()

filename = "cornellbox.obj"

# Load .obj(and .mtl) using default configuration
ret = reader.ParseFromFile(filename)

if ret == False:
    print("Warn:", reader.Warning())
    pint("Err:", reader.Error())
    print("Failed to load : ", filename)

    sys.exit(-1)

if reader.Warning():
    print("Warn:", reader.Warning())

attrib = reader.GetAttrib()
print("attrib.vertices = ", len(attrib.vertices))
print("attrib.normals = ", len(attrib.normals))
print("attrib.texcoords = ", len(attrib.texcoords))

materials = reader.GetMaterials()
print("Num materials: ", len(materials))
for m in materials:
    print(m.name)
    print(m.diffuse)

shapes = reader.GetShapes()
print("Num shapes: ", len(shapes))
for shape in shapes:
    print(shape.name)
    print("num_indices = {}".format(len(shape.mesh.indices)))

More detailed usage

Please take a look at python/sample.py file in tinyobjloader git repo.

https://github.com/syoyo/tinyobjloader/blob/master/python/sample.py

How to build

Using cibuildwheel is an recommended way to build a python module. See $tinyobjloader/azure-pipelines.yml for details.

Developer build

Edit setup.py and uncomment Developer option lines

Assume pip is installed.

$ pip install pybind11
$ python setup.py build

License

MIT license.

TODO

  • Writer saver

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

tinymetabobjloader-2.0.0a0.tar.gz (27.5 kB view hashes)

Uploaded Source

Built Distributions

tinymetabobjloader-2.0.0a0-pp37-pypy37_pp73-manylinux2010_x86_64.whl (174.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (146.2 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-pp36-pypy36_pp73-manylinux2010_x86_64.whl (173.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-pp36-pypy36_pp73-macosx_10_9_x86_64.whl (146.2 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-pp27-pypy_73-manylinux2010_x86_64.whl (174.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-pp27-pypy_73-macosx_10_9_x86_64.whl (146.3 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-cp39-cp39-manylinux2010_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp39-cp39-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp39-cp39-macosx_10_9_x86_64.whl (171.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-cp38-cp38-manylinux2010_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp38-cp38-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp38-cp38-macosx_10_9_x86_64.whl (171.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-cp37-cp37m-manylinux2010_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp37-cp37m-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp37-cp37m-macosx_10_9_x86_64.whl (169.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-cp36-cp36m-manylinux2010_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp36-cp36m-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp36-cp36m-macosx_10_9_x86_64.whl (169.1 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-cp35-cp35m-manylinux2010_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp35-cp35m-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp35-cp35m-macosx_10_9_x86_64.whl (168.9 kB view hashes)

Uploaded CPython 3.5m macOS 10.9+ x86-64

tinymetabobjloader-2.0.0a0-cp27-cp27mu-manylinux2010_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp27-cp27mu-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp27-cp27m-manylinux2010_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ x86-64

tinymetabobjloader-2.0.0a0-cp27-cp27m-manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ i686

tinymetabobjloader-2.0.0a0-cp27-cp27m-macosx_10_9_x86_64.whl (169.8 kB view hashes)

Uploaded CPython 2.7m macOS 10.9+ x86-64

Supported by

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