monkeyman192 / NMSDK

Custom Model importer for NMS
https://monkeyman192.github.io/NMSDK/
29 stars 9 forks source link

Getting importing bones working #77

Closed kidheracles closed 3 years ago

kidheracles commented 3 years ago

MMD_Tools helped me greatly to understand good practice here. I took their bpyutils.py and used it to simplify scene management: switching modes, selecting objects, and linking objects to the scene. I modified other functions in import_scene to use this too, so that they would be easier to follow.

I added a new test which is a simple jelly with a simple animation. Passing that gave me confidence to tackle Toy Cube.

I can see why you have Toy Cube as the test for bones and animations. The issue was that in the Toy Cube model, there are some bones with zero transform And Blender appears to not like it if you create a bone with identical head and tail locations to another bone. What was especially hard with Toy Cube was that three bones in hierarchy were in the same location.

The _add_bone_to_scene was extensively re-written.

Animations still don't animate the mesh, just the bones. That is the next step to tackle, for now, we've gotten as far as the current release.

First though, this file is getting too long. We should split the MBIN parsing from the Blender import logic, that's probably the next step.