- objloader 0.2.0
- История выпусков Уведомления о выпусках | Лента RSS
- Загрузка файлов
- Source Distribution
- Built Distribution
- Хеши для objloader-0.2.0.tar.gz
- Хеши для objloader-0.2.0-py2.py3-none-any.whl
- Помощь
- О PyPI
- Внесение вклада в PyPI
- Использование PyPI
- Saved searches
- Use saved searches to filter your results more quickly
- License
- pywavefront/PyWavefront
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- PyWavefront
- Usage
- Binary Cache
- Visualization
- Generating a Wavefront file with Blender
- Tests
- Community
- Owners & Maintainers
- Contributors
- Project History
objloader 0.2.0
История выпусков Уведомления о выпусках | Лента RSS
Загрузка файлов
Загрузите файл для вашей платформы. Если вы не уверены, какой выбрать, узнайте больше об установке пакетов.
Source Distribution
Uploaded 8 мая 2018 г. source
Built Distribution
Uploaded 8 мая 2018 г. py2 py3
Хеши для objloader-0.2.0.tar.gz
Алгоритм | Хеш-дайджест | |
---|---|---|
SHA256 | ea04ed8c957906922e5a20f6764050263e051e2b56a96d8eba56cc33170ab3f7 | Копировать |
MD5 | 3692fc5b42c5663b39ad3884ff1c2af3 | Копировать |
BLAKE2b-256 | 5d78db8ea5daa28f3d30b9972941209a96ce9edcc86259d51e666179e45ea8ed | Копировать |
Хеши для objloader-0.2.0-py2.py3-none-any.whl
Алгоритм | Хеш-дайджест | |
---|---|---|
SHA256 | f830d1932a8027f9c182fb9e0b7f64f46688add8f6788d324fb36de65e15c127 | Копировать |
MD5 | ad38b329a7417b495d8872e276959f7c | Копировать |
BLAKE2b-256 | 7a7e546bbc7f4e2bb48a4e460cbcf2e0fb4416c5a515dc195d2966c68e59a9eb | Копировать |
Помощь
О PyPI
Внесение вклада в PyPI
Использование PyPI
Разработано и поддерживается сообществом Python’а для сообщества Python’а.
Пожертвуйте сегодня!
PyPI», «Python Package Index» и логотипы блоков являются зарегистрированными товарными знаками Python Software Foundation.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Python library for importing Wavefront .obj files
License
pywavefront/PyWavefront
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
PyWavefront reads Wavefront 3D object files ( something.obj , something.obj.gz and something.mtl ) and generates interleaved vertex data for each material ready for rendering.
A simple (optional) visualization module is also provided for rendering the object(s). The interleaved data can also be used by more modern renderers thought VBOs or VAOs.
Currently the most commonly used features in the specification has been implemented:
- Positions
- Texture Coordinates
- Normals
- Vertex Color
- Material parsing
- Texture and texture parameters
We currently don’t support parameter space vertices, line elements or smoothing groups. Create an issue or pull request on github if needed features are missing.
The package is on pypi or can be cloned on github.
Also check out the roadmap for future plans.
Basic example loading an obj file:
import pywavefront scene = pywavefront.Wavefront('something.obj')
- strict (Default: False ) will raise an exception if unsupported features are found in the obj or mtl file
- encoding (Default: utf-8 ) of the obj and mtl file(s)
- create_materials (Default: False ) will create materials if mtl file is missing or obj file references non-existing materials
- collect_faces (Default: False ) will collect triangle face data for every mesh. In case faces with more than three vertices are specified they will be triangulated. See the documentation of ObjParser#consume_faces() in obj.py .
- parse (Default: True ) decides if parsing should start immediately.
- cache (Default: False ) writes the parsed geometry to a binary file for faster loading in the future
import pywavefront scene = pywavefront.Wavefront( 'something.obj', strict=True, encoding="iso-8859-1", parse=False, ) scene.parse() # Explicit call to parse() needed when parse=False # Iterate vertex data collected in each material for name, material in scene.materials.items(): # Contains the vertex format (string) such as "T2F_N3F_V3F" # T2F, C3F, N3F and V3F may appear in this string material.vertex_format # Contains the vertex list of floats in the format described above material.vertices # Material properties material.diffuse material.ambient material.texture # ..
When cache=True the interleaved vertex data is written as floats to a .bin file after the file is loaded. A json file is also generated describing the contents of the binary file. The binary file will be loaded the next time we attempt to load the obj file reducing the loading time significantly.
Tests have shown loading time reduction by 10 to 100 times depending on the size and structure of the original obj file.
Loading myfile.obj will generate the following files in the same directory.
myfile.obj.bin myfile.obj.json
< "created_at": "2018-07-16T14:28:43.451336", "version": "0.1", "materials": [ "lost_empire.mtl" ], "vertex_buffers": [ < "material": "Stone", "vertex_format": "T2F_N3F_V3F", "byte_offset": 0, "byte_length": 5637888 >, < "material": "Grass", "vertex_format": "T2F_N3F_V3F", "byte_offset": 5637888, "byte_length": 6494208 > ] >
These files will not be recreated until you delete them. The bin file is also compressed with gzip to greatly reduce size.
Pyglet is required to use the visualization module.
import pywavefront from pywavefront import visualization [create a window and set up your OpenGl context] obj = pywavefront.Wavefront('something.obj') [inside your drawing loop] visualization.draw(obj)
The default log level is ERROR . This is configurable including overriding the formatter.
import logging import pywavefront pywavefront.configure_logging( logging.DEBUG, formatter=logging.Formatter('%(name)s-%(levelname)s: %(message)s') )
The examples directory contains some basic examples using the visualization module and further instructions on how to run them.
Generating a Wavefront file with Blender
The following presumes you are using Blender to generate your mesh:
- Using Blender, create a mesh with a UV-mapped texture. The UV-mapping is important! If it is working properly, you will see the texture applied within Blender’s 3d view.
- Export the mesh from Blender using the Wavefront format, including normals.
- Reference your *.obj file as in the pywavefront example above.
All tests can be found in the tests directory. To run the tests:
# Install pywavefront in develop mode python setup.py develop # Install required packages for running tests pip install -r test-requirements.txt # Run all tests pytest # Optionally specific tests modules can be runned separately pytest tests/test_parser.py
- ComFreek
- Daniel Coelho 1danielcoelho
- @dav92lee
- Jerek Shoemaker (intrepid94)
- Marxlp
- Mathieu Lamarre
- Oliv4945
- Patrik Huber (patrikhuber)
- Sérgio Agostinho (SergioRAgostinho)
- Zohar Jackson
- hkarrson (hkarrson)
PyWavefront was originally started by @greenmoss (Kurt Yoder) in 2013. He was the sole maintainer of the project until February 2019 when the PyWavefront Maintainers organization was created adding @einarf (Einar Forselv) as an additional owner and maintainer of the project.
PyWavefront
PyWavefront reads Wavefront 3D object files ( something.obj , something.obj.gz and something.mtl ) and generates interleaved vertex data for each material ready for rendering.
A simple (optional) visualization module is also provided for rendering the object(s). The interleaved data can also be used by more modern renderers thought VBOs or VAOs.
Currently the most commonly used features in the specification has been implemented:
- Positions
- Texture Coordinates
- Normals
- Vertex Color
- Material parsing
- Texture and texture parameters
We currently don’t support parameter space vertices, line elements or smoothing groups. Create an issue or pull request on github if needed features are missing.
The package is on pypi or can be cloned on github.
Also check out the roadmap for future plans.
Usage
Basic example loading an obj file:
- strict (Default: False ) will raise an exception if unsupported features are found in the obj or mtl file
- encoding (Default: utf-8 ) of the obj and mtl file(s)
- create_materials (Default: False ) will create materials if mtl file is missing or obj file references non-existing materials
- collect_faces (Default: False ) will collect triangle face data for every mesh. In case faces with more than three vertices are specified they will be triangulated. See the documentation of ObjParser#consume_faces() in obj.py .
- parse (Default: True ) decides if parsing should start immediately.
- cache (Default: False ) writes the parsed geometry to a binary file for faster loading in the future
Binary Cache
When cache=True the interleaved vertex data is written as floats to a .bin file after the file is loaded. A json file is also generated describing the contents of the binary file. The binary file will be loaded the next time we attempt to load the obj file reducing the loading time significantly.
Tests have shown loading time reduction by 10 to 100 times depending on the size and structure of the original obj file.
Loading myfile.obj will generate the following files in the same directory.
myfile.obj.bin myfile.obj.json
These files will not be recreated until you delete them. The bin file is also compressed with gzip to greatly reduce size.
Visualization
Pyglet is required to use the visualization module.
The default log level is ERROR . This is configurable including overriding the formatter.
The examples directory contains some basic examples using the visualization module and further instructions on how to run them.
Generating a Wavefront file with Blender
The following presumes you are using Blender to generate your mesh:
- Using Blender, create a mesh with a UV-mapped texture. The UV-mapping is important! If it is working properly, you will see the texture applied within Blender’s 3d view.
- Export the mesh from Blender using the Wavefront format, including normals.
- Reference your *.obj file as in the pywavefront example above.
Tests
All tests can be found in the tests directory. To run the tests:
python setup.py develop pip install -r test-requirements.txt pytest pytest tests/test_parser.py
Community
Owners & Maintainers
Contributors
- ComFreek
- Daniel Coelho 1danielcoelho
- @dav92lee
- Jerek Shoemaker (intrepid94)
- Marxlp
- Mathieu Lamarre
- Oliv4945
- Patrik Huber (patrikhuber)
- Sérgio Agostinho (SergioRAgostinho)
- Zohar Jackson
- hkarrson (hkarrson)
Project History
PyWavefront was originally started by @greenmoss (Kurt Yoder) in 2013. He was the sole maintainer of the project until February 2019 when the PyWavefront Maintainers organization was created adding @einarf (Einar Forselv) as an additional owner and maintainer of the project.