All Projects → paulmelis → blender-ply-import

paulmelis / blender-ply-import

Licence: BSD-2-Clause license
A Python module for faster import of PLY models in Blender

Programming Languages

c
50402 projects - #5 most used programming language
HTML
75241 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to blender-ply-import

Tree Gen
Procedural generation of tree models in blender
Stars: ✭ 465 (+2347.37%)
Mutual labels:  blender, 3d-models
NeuroMorph
The NeuroMorph analysis and visualization toolkit
Stars: ✭ 57 (+200%)
Mutual labels:  blender, 3d-models
3d models
3D Models of our products
Stars: ✭ 177 (+831.58%)
Mutual labels:  blender, 3d-models
mcthings
A Python framework for creating 3D scenes in Minecraft and Minetest
Stars: ✭ 44 (+131.58%)
Mutual labels:  blender, 3d-models
Mod3-MHW-Importer
Blender Mod3 Import-Exporter for Monster Hunter World
Stars: ✭ 44 (+131.58%)
Mutual labels:  importer, blender
story-unity3D
Horror Game Development
Stars: ✭ 32 (+68.42%)
Mutual labels:  blender, 3d-models
ecad-models
Random 3D models and such for CAD/ECAD
Stars: ✭ 18 (-5.26%)
Mutual labels:  3d-models
BlenderGameRig
Rigging framework for game development. Hard fork from Rigify.
Stars: ✭ 53 (+178.95%)
Mutual labels:  blender
3-D-Scene-Graph
3D scene graph generator implemented in Pytorch.
Stars: ✭ 52 (+173.68%)
Mutual labels:  3d-models
DuBLF DuBlast
Quick Playblast tool for Blender
Stars: ✭ 18 (-5.26%)
Mutual labels:  blender
dometyl-keyboard
A parametric generator for designing split, concave, ergonomic keyboards written in ocaml.
Stars: ✭ 84 (+342.11%)
Mutual labels:  3d-models
blender-robotics-utils
Set of utilities for exporting/controlling your robot in Blender
Stars: ✭ 26 (+36.84%)
Mutual labels:  blender
BlenderRenderController
A tool for significant speedup of rendering with Blender VSE (Video Sequence Editor).
Stars: ✭ 25 (+31.58%)
Mutual labels:  blender
neuro-bge
Node-based Blender game engine and logic editor addon for Blender
Stars: ✭ 27 (+42.11%)
Mutual labels:  blender
astutils
Bare essentials for building abstract syntax trees, and skeleton classes for PLY lexers and parsers.
Stars: ✭ 13 (-31.58%)
Mutual labels:  ply
blender-importer-unity
A tool to fix orientation issues from Blender to Unity
Stars: ✭ 23 (+21.05%)
Mutual labels:  blender
FireVR
Blender to JanusVR FireBoxHTML Exporter Addon (with IPFS support)
Stars: ✭ 25 (+31.58%)
Mutual labels:  blender
VSE Transform Tools
Quickly transform, crop and fade video strips in Blender's Video Sequence Editor
Stars: ✭ 195 (+926.32%)
Mutual labels:  blender
UEShaderScript
UEShaderScript is a free Blender Plugin that allows for saving and dynamically loading shader maps and textures. It is built for all 3d assets exported from Unreal Engine.
Stars: ✭ 26 (+36.84%)
Mutual labels:  blender
blender-mqo
Blender Add-on: Metasequoia File Importer/Exporter
Stars: ✭ 27 (+42.11%)
Mutual labels:  blender

readply - a Python extension module for fast(er) import of PLY files in Blender

The default PLY importer in Blender is quite slow when it comes to import large mesh files. Most Python-based importers suffer from this because during import Python data structures are built up holding all geometry, vertex colors, etc. This simply takes quite a lot of time (and memory).

Fortunately, Python objects that support the buffer protocol can be passed in certain places of the Blender Python API. We can use this functionality to pass chunks of memory containing vertex and face data, without having to build up Python data structures. We use NumPy arrays in the readply extension module to easily pass the data directly to Blender.

Example usage:

$ blender [<scene.blend>] -P mesh_readply.py -- myfile.ply

Notes:

  • The readply module is not tied to Blender in any way and can be used as a general PLY reader in Python.
  • Compared to 2.7 the 2.8x version of Blender already improves on the import time in the example below. Memory usage in 2.8x also improved substantially. But the speed improvement using this module is still of the same order (roughly 6x).
  • There was a Google Summer of Code 2019 project for creating new faster Blender importers for PLY, STL and OBJ. The results unfortunately do not seem to be merged with mainline Blender at the moment. If that ever happens this module will probably become obsolete as far as its use in Blender is concerned.
  • Development and testing is done on Linux, but the module should compile and work under different operating systems

Performance

Below are some numbers when importing the Asian Dragon model [1] from The Stanford 3D Scanning Repository [2]. This 3D model consists of 3,609,600 vertices and 7,219,045 triangles.

With Blender 2.81 and xyzrgb_dragon.ply already in the filesystem cache:

# Native blender PLY importer (bpy.ops.import_mesh.ply())
$ blender -P test/blender_native_import.py -- xyzrgb_dragon.ply
total                           43.538 sec

# mesh_readply.py using readply extension module
$ blender -P mesh_readply.py -- xyzrgb_dragon.ply
reaply():                        0.631s
blender mesh+object creation:    5.226s
total                            5.857s

I.e. in this test the mesh_readply.py script (which uses the readply module) loads the Dragon model 7.4x faster into Blender than Blender's own PLY import script.

  1. http://graphics.stanford.edu/data/3Dscanrep/xyzrgb/xyzrgb_dragon.ply.gz
  2. http://graphics.stanford.edu/data/3Dscanrep/

Building

A setup.py script is provided to build the extension, either under regular Python or with Blender's included version of Python.

Note that for Blender usage it is advised to build and install the module using Blender's Python version, as that will take care of placing the module in the correct location.

Blender

Note: the official Blender binaries do not include the Python headers. So you still need a full Python installation somewhere to build the readply extension.

Run the setup.py script with Blender's copy of the Python interpreter. There should be a python3.7m executable in your Blender directory. For example, for 2.81 on Linux the Python binary is located at <blender-dir>/2.81/python/bin/python3.7m. Then run

$ <blender-dir>/2.81/python/bin/python3.7m setup.py install

If you get an error regarding the setuptools module not being found, then run .../python3.7m -m ensurepip which should install the pip module, followed by installing the setuptools module.

An alternative way is to run the setup script under Blender:

$ blender -b -P setup.py

General Python

There's at least two options:

# Build the module, then copy it to the top-level directory
$ python setup.py build_ext --inplace

or

# Build the module, then copy it to the default Python module location
# (which might be a system-wide directory)
$ python setup.py install

Notes

  • Make sure that the version of NumPy used for compiling the readply extension has the same API version as the one that is used by Blender (the official binary distributions of Blender include a version of NumPy)
  • The readply extension module can be compiled for both Python 2.x and 3.x, even though Blender uses Python 3.x
  • Texture coordinates may be stored in s+t or u+v vertex fields, depending on what property names the PLY file being read uses

Bugs

  • The module is currently not usable as a drop-in replacement of the built-in PLY import in Blender
  • It is assumed that if the PLY file includes vertex coordinates they are defined in x, y and z order (the PLY header allows properties in any order).

Author

Paul Melis ([email protected]), SURFsara Visualization group

The files under the rply/ directory are a copy of the RPly 1.1.4 source distribution (see http://w3.impa.br/~diego/software/rply/).

License

See the LICENSE file in the root directory of this distribution, which applies to all files except the ones in the rply/ directory.

See rply/LICENSE for the the license of the RPly sources.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].