Transforms and Positioning the Mesh - BadDogSkyrim/PyNifly GitHub Wiki

There are multiple transforms in the nif to get the mesh where it should be in game, especially for skinned nifs. Mostly you won't need to worry about this but if you need to care:

  • The vertices themselves are given specific positions. However, this position is altered by a set of transforms--translations, rotations, and scale applied to all vertices.
  • Each NiNode that represents a bone has a transform: This is the pose position of the bone used in this nif. Usually it's the vanilla position, but not necessarily. It's where the bone should be positioned in space when not rigged to a skeleton. (But when the shape is rigged to a skeleton, the skeleton's bone position rules.)
  • The TriShape (of whatever variety) has a transform. If the TriShape is not skinned, this transform alters the position of the TriShape. That way you can design your mesh around the origin and then position it elsewhere. If the TriShape is skinned, this transform is ignored.
  • A shape's skin has a transform on the NiSkinData node (Skyrim only): It sets an overall transform for all the bones used by the shape. Called the global-to-skin transform in Nifly.
  • Skin-to-bone transforms for each bone the shape is weighted to. This defines the "bind" position of the bone, the relative position of the bone in the skeleton. They are also used so a body part can be designed around the origin but moved to the right place on the body. This is important for Fallout 4, which uses single-precision for vertex locations. If head parts were designed in their proper position, the vertex locations would be large enough to introduce errors. In Skyrim, this means head parts all show at the origin when the mesh is not skinned, as in viewing the head in Creation Kit.
    • In Blender, the global-to-skin transform is applied to the object that represents the mesh. It will appear in its skinned location, but if you look at the local vertex coordinates you'll see they're all around the origin. The transform can be seen in the Object Properties/Transform panel. Copy the vanilla transforms in your meshes and they'll behave the same way.
    • The bones' pose positions are loaded as the armature's pose in Blender.
    • There's no way to import a mesh that has multiple, different bind positions in the different shapes. If there's any reason to support this let me know.
    • If you import such a nif all by itself, the bones will import at the position they have in the nif. If you then re-parent your Blender object to an armature representing the vanilla skeleton, it will not deform as intended. Any normal meshes that you parent to the armature with the bones out of place will be deformed similarly.
    • If you import the vanilla skeleton, or import a nif that has all the bones in the right positions, select that armature and import the nif with the out-of-place bones, the mesh will be deformed to conform to the vanilla skeleton and you can work on it normally.

Special note for FO4 body parts

FO4 body parts are designed so the next seam is near the origin (ground level). This is because FO4 nifs use half-precision floats and if the neck and head were designed where they appear in game, the vertex positions don't have enough precision to show up correctly. The body parts are lifted into position by their skin-to-bone transforms as described above.

This is a problem for the blender import because the transform has to be generated by averaging all the skin-to-bone transforms in the skinned mesh, and different body parts can have slightly different transforms. Plus, the averaging process introduces errors. So the importer provides two workarounds:

  • One is to turn off the whole averaging process entirely. The shape will appear at the origin in editing mode. It's a bit of a pain to work with, but you get exactly what's in the nif.
  • Two, if the calculated average is close to the standard translation for body parts the importer snaps to a canonical translation. This way all body parts show up in the right positions in blender, even if their translation is a bit different in the nif.

Mostly this won't matter, but when you're trying to get wrist and neck seams to line up exactly this may be a help.