Skip to main content

Experimental fork of tinyobjloader Python module

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.

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

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-0.1.1.tar.gz (22.9 kB view hashes)

Uploaded Source

Built Distributions

tinymetabobjloader-0.1.1-cp37-cp37m-win_amd64.whl (120.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

tinymetabobjloader-0.1.1-cp37-cp37m-win32.whl (104.2 kB view hashes)

Uploaded CPython 3.7m Windows x86

tinymetabobjloader-0.1.1-cp37-cp37m-macosx_10_6_intel.whl (300.8 kB view hashes)

Uploaded CPython 3.7m macOS 10.6+ intel

tinymetabobjloader-0.1.1-cp36-cp36m-win_amd64.whl (120.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

tinymetabobjloader-0.1.1-cp36-cp36m-win32.whl (104.2 kB view hashes)

Uploaded CPython 3.6m Windows x86

tinymetabobjloader-0.1.1-cp36-cp36m-macosx_10_6_intel.whl (300.8 kB view hashes)

Uploaded CPython 3.6m macOS 10.6+ intel

tinymetabobjloader-0.1.1-cp35-cp35m-win_amd64.whl (122.5 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

tinymetabobjloader-0.1.1-cp35-cp35m-win32.whl (102.1 kB view hashes)

Uploaded CPython 3.5m Windows x86

tinymetabobjloader-0.1.1-cp35-cp35m-macosx_10_6_intel.whl (300.8 kB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

tinymetabobjloader-0.1.1-cp34-cp34m-macosx_10_6_intel.whl (300.7 kB view hashes)

Uploaded CPython 3.4m macOS 10.6+ intel

tinymetabobjloader-0.1.1-cp27-cp27m-macosx_10_6_intel.whl (302.4 kB view hashes)

Uploaded CPython 2.7m macOS 10.6+ intel

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