The new accessor functions are in AnimInfo. If the shape is skinned, they access AnimSkin::xformGlobalToSkin. If the shape is unskinned, they access the shape's node-to-global transform from workNif. The purpose of this is so that skinned and unskinned meshes can be treated the same when it comes to this important transform.
The reason these accessor functions need to be in AnimInfo and not, say, OutfitProject, is that some of the places where this information is needed (Automorph and FBXWrangler) don't have access to OutfitProject but do have access to AnimInfo.
I searched for all instances of xformGlobalToSkin outside Anim.{h,cpp} and replaced them with calls of the accessor functions. This had the following benefits:
ShapeProperties shows the same transform for both skinned and unskinned.
FBX export might work for unskinned shapes now.
The weld option to the move-vertex tool should work for unskinned shapes.
The copy-skin-coordinates option to ImportOBJ works now, fixing issue #432 .
ResetTransforms now should have the same effect on unskinned shapes as it has on skinned. Before, it did nothing on unskinned shapes.
The Copy Bone Weights dialog now correctly shows the transform options for unskinned shapes.
Some code was simplified.
I also added CreateSkinning and RemoveSkinning functions to OutfitProject that wrap the NifFile functions CreateSkinning and DeleteSkinning. These functions make sure the transforms between shape and global coordinates do not change when the shape is skinned and unskinned. I searched for all calls of the NifFile functions and replaced them.
I also made sure AnimInfo::refNif is initialized on construction and never set to nullptr.
While this PR does not directly fix issue #429 , it does open up new options:
The user can copy a good transform from the reference shape on ImportOBJ. But this only makes sense if the shape's vertices are already in the reference's shape coordinate system; if they're in global coordinates, copying the transform will misplace the shape.
The user can set a good transform in Shape Properties immediately after ImportOBJ, and this transform will be preserved.
Copy Bone Weights now shows the right options, so it can set a good transform.
The new accessor functions are in AnimInfo. If the shape is skinned, they access AnimSkin::xformGlobalToSkin. If the shape is unskinned, they access the shape's node-to-global transform from workNif. The purpose of this is so that skinned and unskinned meshes can be treated the same when it comes to this important transform.
The reason these accessor functions need to be in AnimInfo and not, say, OutfitProject, is that some of the places where this information is needed (Automorph and FBXWrangler) don't have access to OutfitProject but do have access to AnimInfo.
I searched for all instances of xformGlobalToSkin outside Anim.{h,cpp} and replaced them with calls of the accessor functions. This had the following benefits:
ResetTransforms now should have the same effect on unskinned shapes as it has on skinned. Before, it did nothing on unskinned shapes.I also added CreateSkinning and RemoveSkinning functions to OutfitProject that wrap the NifFile functions CreateSkinning and DeleteSkinning. These functions make sure the transforms between shape and global coordinates do not change when the shape is skinned and unskinned. I searched for all calls of the NifFile functions and replaced them.
I also made sure AnimInfo::refNif is initialized on construction and never set to nullptr.
While this PR does not directly fix issue #429 , it does open up new options: