Blender Clothes Cycle - enimaroah/SB3Utility GitHub Wiki
We begin the cycle with an import from Sb3UGS. I had exported the original long KK gloves, and imported the FBX in Blender 2.90.1.
The skinned mesh shows some translation and it has lost its original Parent Bone. For fixing the parent bone we need to set the Armature's rotation from 90 to 0.
Now everything lies flat on the floor. Make the future mesh parent the only active bone, add select the mesh. Make sure that you are in Object Mode when you set the Parent Bone.
Great, now revert the Armature's rotation back to 90. Next Apply the mesh's translation.
Even better, the mesh looks like shortly after import, but it is now corrected and allows to be exported. The FBX exporter does it right here.
In Unity editor we create an AssetBundle file for the gloves:
In your project folder is an Assets/Editor folder e.g. ...\KKModdingTools\Assets\Editor. The following script will never be executed from the game, it is for Unity editor itself and removes unused bones from the imported meshes: BlenderFBX_Postprocessor.cs.
- Select the FBX file. I had put it into ...\KKModdingTools\Assets\Mods. Change the import options. Don't forget to Apply.
-
Drag the FBX file somewhere into the scene. Expand it there to reach p_o_gloves_long. Set the Layer to CHARA, confirm that you want that for children as well, add a ChaClothesComponent MB in which you register the SkinnedMeshRenderer in rendNormal.
-
Drag p_o_gloves_long down to create a prefab and assign an AssetBundle filename.
Then build the AssetBundle, or zipmod and test it in game.
Inspecting the AssetBundle has some surprises for us.
-
The bounding box of the mesh greatly differs from the original. That is because of the Bind Poses - Bone Matrices in Sb3UGS. They are a remainder of Blender's FBX importer when the local coordinates were transformed for breaking free from the Bone Parent or from Blender's "Apply" of the translation. For that reason Sb3UGS shows mismatching Bind Poses in the tooltip. This means that the mesh in not in "Rest Pose", and computing the rest pose in that state would shift the mesh in an unwanted way. If we would want to revert that in Sb3UGS, we would use the FBX exported from Blender using "WorldCoordinate" option and additionally we would have to compute the "Rest Pose" after replacement.
-
The number of Bone Hashes is still very high and not aligned with Bones / Bind Pose. Luckily, Unity doesn't use them. Their hash values are computed for the original hierarchy beginning with Armature which is not longer inside the prefab.