GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tinyobjloader/python at release · EinOnly/tinyobjloader

Expand file tree

/

python

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

python

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
bindings.cc
bindings.cc
 
 
sample.py
sample.py
 
 
tiny_obj_loader.cc
tiny_obj_loader.cc
 
 

README.md

Outline

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.

Requirements

  • python 3.6+

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 a recommended way to build a python module. See $tinyobjloader/azure-pipelines.yml for details.

Developer build

Assume pip is installed.

$ git clone https://github.com/tinyobjloader/tinyobjloader
$ cd tinyobjloader
$ python -m pip install .

License

MIT(tinyobjloader) and ISC(mapbox earcut) license.

TODO

  • Writer saver
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.