Skip to content

Manipulating the skeleton

eArmada8 edited this page Oct 28, 2023 · 3 revisions

Manipulating the skeleton

Here is a basic tutorial on how to get the skeleton into and out of Blender for folks who want to preview how meshes change with animation, and for those need to modify the skeleton (adding, moving, deleting bones) or weight paint. This tutorial assumes you have properly setup the toolset.

Skeletal rigging and weight painting

For weight painting, you will want to rig your meshes to the skeleton. We will not be using the actual meshes in the glTF file because they cannot be exported.

  1. I will be decompiling Agnès' Aramis Uniform (chr5001_c03.mdl). Obtain and unpack your model. Run kuro_mdl_to_basic_gltf.py by double-clicking the script and it will unpack your model and convert it to .glb format. When both scripts are done, you will have a folder with your unpacked model, and a chr5001_c03.glb file.

NOTE: Instead I actually recommend running both kuro_mdl_export_meshes.py and kuro_mdl_to_basic_gltf.py from the command line. In the same method as outlined in the basic tutorial, type cmd into the address bar of the windows explorer menu, then type:

python kuro_mdl_export_meshes.py
python kuro_mdl_to_basic_gltf.py

Python will not report any errors if the script crashes when you double-click the script, and no one will be able to help you. Run from the command line for helpful error messages.

  1. Open the glTF file (chr5001_c03.glb). (File menu -> Import -> glTF (.glb + .gltf)) You can hide or delete the glTF meshes, they cannot be exported. I generally just delete them. I also hide the joints, so you can clearly see the bones and mesh.

  2. Load your meshes into Blender. (File menu -> Import -> 3DMigoto raw buffers (.vb + .ib)) The meshes are in {Work Folder}/chr5001_c03/. These are the meshes you can make changes to.

  3. Select all your meshes (in the list on the upper right, click the top one, then shift-click the bottom one). Then SHIFT-click on one of the bones (in the scene, NOT on the list). You should see the meshes outlined in red, and the skeleton outlined in orange. Press Ctrl-P to parent, and select "Armature Deform." Do NOT pick any of the "With..." options.

The model is rigged! You can now do what you need to do.

Modifying a skeleton in Blender

WARNING: Please note that modifying the skeletons necessitates making new animations for the model. 99% of modders should completely ignore this tutorial - for the 1% who need this: you know who you are.

  1. Obtain and unpack your model. Run kuro_mdl_to_basic_gltf.py by double-clicking the script and it will unpack your model and convert it to .glb format. (A second file, chr5001_c03.metadata, will be created; this file has the list of locators and can be directly edited.)

  2. Import the .glb file into Blender. Set Bone Dir to "Blender (best for re-importing)", or Blender will modify the skeleton.

  1. The skeleton is now in Blender, ready to modify.

  1. When you are done editing the skeleton, export as .glb/.gltf (File menu -> Export -> glTF 2.0). Turn on Tangents export (Geometry -> Mesh -> Tangents). Also, if your original model was not +Y Up, then be sure Transform -> +Y Up is checked (this only applies to using models not originally from the game). For all other options, use default settings.

  2. If you already have a folder with an unpacked model of the same name, delete it. (Back it up first if you made changes, etc.) Blender changes the mesh order, which will result in all new mesh files with different file names. kuro_mdl_import_meshes.py will know which set to import and which to ignore, but you may become confused and edit the wrong set of meshes. It is best to just start clean. If you have made changes to the materials, back those up!)

  3. Run kuro_gltf_to_meshes.py. It will create a folder for each .glb/.gltf. Inside the folder will be the new skeleton along with all the bone palettes and meshes that are parented to that skeleton. (The .fmt/.ib/.vb/.vgmap files, mesh_info.mdl, skeleton.mdl, and mdl_version.mdl will all be present.)

Note: kuro_gltf_to_meshes.py does not generate any material data at this time. If you are not making material changes, proceed directly to the next step and kuro_mdl_import_meshes.py will read the material data from the original .mdl file. If materials have been changed, be sure to put the material_info.json in the meshes folder.

  1. Repack the model by running kuro_mdl_import_meshes.py. It will rebuild the mdl using the new skeleton.

Note about weight-painting vs modifying the skeleton

If you only need to weight-paint and you do not need to export the skeleton, you can import into Blender with Bone Dir set to "Temperance (Average). This will allow Blender to properly orient the bone orientations. This will permanently destroy the skeleton internally however, as you can see:

Note that you do not need to use "Temperance (Average)" for weight-painting; this setting is mainly for comfort. If you need to weight paint AND modify the skeleton, use "Blender (best for re-importing)" instead.