libigl / libigl-python-bindings

libigl python bindings
https://libigl.github.io/libigl-python-bindings/
GNU General Public License v3.0
315 stars 62 forks source link

Adding a script to export igl assets from blender #189

Closed kishoreVen closed 1 year ago

kishoreVen commented 1 year ago

Exporting IGL Assets from Blender

Context

I created a deformable mesh with a skeleton and it's corresponding skinning weights in blender. However, I wasn't able to find any tooling to export libigl compatible assets.

Solution

So I created this script to export

How to Use

  1. In the scripting tab of the Blender layout, load the blender_script_export.py Screenshot from 2023-03-02 20-45-51

  2. Select the parent Armature in the scene inspector of the editor Screenshot from 2023-03-02 23-14-05

Key Notes: a. The armature used for rigging needs to match the name of the parent selected for export. b. It's best to set the highest level bone of the armature as "root". If you intend to use a different name, update this line in the script. Screenshot from 2023-03-02 23-15-29 c. You can optionally control what to export in the settings on the top right Screenshot from 2023-03-04 23-29-27

  1. Provide a path with an asset name on where to export the file. You do not need to provide any extension. Navigate straight to the folder and provide an asset name like shown.
  2. Hit "Export" and the script should do the rest. Screenshot from 2023-03-02 20-52-37

Debugging

I dump out a blender_igl_export.log file to ~/Documents/. This should provide a good set of progress, errors or warnings.

Remaining Questions

  1. Is this script even needed for other folks?
  2. If answer to 1. is yes, then is this the right location for the script?
  3. Any further optimizations needed?

Proof of life

  1. Loading the cylinder from blender using libigl. The image also shows the root bone's skin paint. Screenshot from 2023-03-04 23-31-16

Here is what it looks like in blender Screenshot from 2023-03-04 23-33-21

  1. Comparing the animation loaded from dmat vs animation loaded as npy Screenshot from 2023-03-04 23-27-23

  2. Comparing frame 31 of animation in igl vs blender (in order) Screenshot from 2023-03-05 00-09-13

Here is what it looks like in blender Screenshot from 2023-03-05 00-08-53

alecjacobson commented 1 year ago

This is really cool. I'm going to merge, but I wonder if this is the best place for this? I don't think this is going to get included in the pypi distribution as part of the bindings, right?