跳转到主要内容

Python模块,用于tinyobjloader

项目描述

tinyobjloader,Wavefront .obj加载器

tinyobjloader是C++ wavefront .obj加载器的Python封装。与纯Python版本的.obj加载器相比,tinyobjloader速度更快,功能更丰富。

快速教程

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)))

更详细的用法

请查看tinyobjloader git repo中的python/sample.py文件。

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

许可证

MIT许可证。

待办事项

  • 写入保存器

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源代码分发

tinyobjloader-0.1.tar.gz (3.1 kB 查看哈希值)

上传时间 源代码

构建分发

tinyobjloader-0.1-cp36-cp36m-manylinux1_x86_64.whl (1.4 MB 查看哈希值)

上传时间 CPython 3.6m

由...