Skip to main content

An obj model loader for Python

Project description

PyObjLoader

An obj model loader for python. Currently will only return a numpy array of vertices containing position, uv, and normals.

Setup

Run the install command

pip insall pyobjloader

Import

Import the load function

from pyobjloader import load_model

Use

To get the numpy array of vertices, first setup a directory containing the .obj

project
--- main.py
--- my_model_directory
--- --- my_model.obj

Then pass the directory into the load function

vertex_array = load_model('my_model_directory')

Format

The format of the returned array is as follows:

# ModernGL Specifications
vertex_format = '3f 2f 3f'
vertex_attribs = ['in_position', 'in_texcoord', 'in_normal']

Example with ModernGL

Here is an example VAO made with ModernGL and PyObjLoader

# Make sure you have a context and shader program (see moderngl docs)
ctx = ...
program = ...

# Load the model using pyobjloader
vertex_array = load_model('my_model_directory')

# Make a vertex buffer object with the vertex data
vbo = ctx.buffer(vertex_data)

# VBO Formatting
vertex_format = '3f 2f 3f'
vertex_attribs = ['in_position', 'in_texcoord', 'in_normal']

# Create a vertex array object
vao = ctx.vertex_array(program, [(vbo, vertex_format, *vertex_attribs)])

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

pyobjloader-0.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyobjloader-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file pyobjloader-0.0.1.tar.gz.

File metadata

  • Download URL: pyobjloader-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for pyobjloader-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b13d1513295b84abb70cd27612d0cfc37eabda88cd9c04c5e7d1f8904c652044
MD5 fb062f39095b8596e3e5aa97a482cecb
BLAKE2b-256 dd8fac7d5d22221fce7d84d0d0717b5622626eab12d26dcbde356c57af01a71f

See more details on using hashes here.

File details

Details for the file pyobjloader-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyobjloader-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for pyobjloader-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e5cf2cd1226ea13ea7cebd05a410c32e5f014000aef1af3c54d0ec3a64bbabd
MD5 9ae9725d47342c6d6d6a18900cf4c3c5
BLAKE2b-256 4b45e90df2dde3d504fb9856d414a8295b8eef1dfa35bf169be163ec37d56d1b

See more details on using hashes here.

Supported by

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