User:DavidJCobb/Tutorials/Editing NIFs

Bethesda's RPGs, including Skyrim, use the NetImmerse Format for their 3D models. This format is not open-source, but the modding community has reverse-engineered it and developed a set of tools for working with it; however, these tools can be tricky to find and set up.

ToolsEdit

NifSkope
NifSkope is the primary tool for viewing and editing NIFs. It's not suitable for 3D editing, but it's vital for modifying the various data structures and metadata values inside of a model.
Blender
Blender is a free and open-source 3D modeling program. If you can't afford the specific versions of 3ds Max that Bethesda used for their NIF work, then you're going to be using Blender to create models and make significant changes to existing ones. As of this writing, Blender 2.7 can be extended to support modern NIFs with a limited featureset, while Blender 2.49b can be extended to support old (pre-Skyrim) NIFs with a larger featureset.
Blender NIF plug-in
As of this writing, all versions of the NIF plug-in can be found here. Plug-in versions 60 and up are for modern versions of Blender, while older versions of the plug-in are for Blender 2.49b.
Note that modern versions of the plug-in are a work in progress; there is still a lot of data (such as animations) that can only be edited in Blender 2.49b.
NifUtilsSuite
A GUI tool used to extract and insert non-convex collision meshes into NIFs, convert NIFs for use with Blender 2.49b, and convert Fallout 3 NIFs to Skyrim NIFs (albeit with some data loss).
To use this program with NifSkope 2.0, you will need to modify NifUtilsSuite.xml. Find the <MatScanName></MatScanName> tags and make sure there's nothing between them. You can still use NifUtilsSuite without making this change, but it won't define collision materials (i.e. sounds and hardness) properly without it. Remember to also tell NifUtilsSuite where NifSkope's "nif.xml" file is (you do have to do that).

Setting up Blender 2.49b to edit old NIF filesEdit

These steps will guide you through installing Blender 2.49b alongside a modern version of Blender. Before you begin, there's something you'll need to double-check regarding any versions of Python installed on your system: they must all be installed to their default directories, and you must not have a PYTHONPATH environment variable defined on your system. PYTHONPATH is used when installing Python to a non-default location, but it can't adequately handle different versions of Python. If you try to use it to accommodate multiple Blender versions, you will render at least one of those versions unusable: it will crash on startup.

If you're using PYTHONPATH, delete it, uninstall all Python versions, and reinstall them to their default directories. Once that's out of the way, the steps to preparing Blender 2.49b for NIF work are as follows:

1. Download Blender 2.49b. You want the 32-bit version in a ZIP archive. Install it by extracting it to wherever you like.

2. Get the last version of the old Blender NIF scripts. Extract the contents of its "scripts" folder into Blender 2.49b's own "scripts" folder.

3. Get Python 2.6.6, 32-bit. Install it to its default directory.

The NIF scripts require APIs that are only present in the 32-bit binaries for Python 2.6.6, so you need 32-bit Python and 32-bit Blender.

4. Download PyFFI 2.1.9 as both an EXE installer and a ZIP. Run the EXE installer, and if it allows you to select Blender 2.4 in its options, then do so. If it doesn't, then run the installer anyway, and then open the ZIP: find the "pyffi" folder and extract it to Blender 2.49b's ".../scripts/bpymodules" folder (i.e. you should have ".../bpymodules/pyffi/").

Note that PyFFI will add a context menu item to Windows without your knowledge or consent.

That should be all. :)

NotesEdit

  • When Blender is installed via an EXE installer, you will be able to choose where it stores its preferences. When Blender is distributed via a RAR or ZIP archive, it will store its preferences within its installation directory, preventing it from interfering with the user preferences of other Blender installations.
  • "32-bit" and "x86" mean pretty much the same thing.

NotesEdit

  • When exporting a NIF from modern versions of Blender, Oblivion is the default selection. Remember to change it to Skyrim.
  • When exporting a NIF from modern versions of Blender, be sure to check the NIF properties at the bottom of the Scene data. You want the "user versions" to be 12 and 83. If you try to use NifSkope to paste data between NIFs with different versions, you will end up with broken pastes and corrupted data. Note that if you start from scratch rather than importing a NIF into Blender, these numbers default to zero, which is... not ideal.
    • Every time you import a NIF into Blender, the scene's NIF versions will be set to those of the imported NIF. If you import multiple NIFs with non-matching versions, you'll want to double-check to make sure that your scene is still set to 12/83.
  • A shape within a NIF file can have shader data (e.g. textures) and alpha data, which can be stored in two "BS Properties" slots on the node. When you copy and paste alpha data across or within files, NifSkope treats these slots as interchangeable. They are not. The first BS Property must be empty or shader data; the second BS Property must be empty or alpha data; and if the two are ever switched around, your NIF will crash the Creation Kit and Skyrim.
    • If the "BS Properties" slots on a node are greyed out, you have exported your NIF from Blender with the wrong user version numbers. Fix them and export again.
  • To make meshes that aren't affected by physics (i.e. they can't be moved around), modify all "rigid body" blocks in NifSkope and set their mass to zero.
  • When applying translation or size values to Havok objects, you'll find that they don't use the same unit of measurement as everything else.
Havok units = (normal units / 512) * 7.3152.
Normal units = Havok units * 512 / 7.3152
  • Two BSLightingEffectShaders can reuse the same texture list, but two NiTriShapes cannot reuse the same BSLightingEffectShader block. Trying it will make your NIF crash the Creation Kit and Skyrim. Give them separate-but-identical blocks instead.
  • NIFs exported from Blender may not always light and shade properly. Using NifSkope to "Face Normals" and "Update Tangent Spaces" may fix this. However, some shapes don't compute tangent vectors properly (when exporting or when using NifSkope), and you may need to hand-edit them.
  • NifUtilsSuite will crash if you specify a non-existent input file.
  • To import an armor/body mesh into Blender 2.49b without losing the skin partitions, you need to use NifSkope to change the slots that those partitions use. Edit the BSDismemberSkinInstance and change all SBP_* partitions (Skyrim) to BP_* partitions (Fallout 3). The changes don't need to make sense; feel free to map Skyrim's "calves" slot to Fallout 3's "brain" slot. Do that, import your mesh into Blender, and after you export, change the slots back in NifSkope.
  • To export an armor/body mesh from Blender 2.49b, there are a few steps you need to take. First, select all vertices in your model and in the Editing Panel, click Set Smooth; if the faces are shaded flatly (which is the default), then the NIF scripts will actually split their edges (effectively duplicating all vertices) in an attempt to maintain that shading. Once that's taken care of, you can export: use Fallout 3 and disable all "stripify" options. Once you have a Fallout 3 NIF, you can use NifUtilsSuite's NifConvert to turn it into a Skyrim NIF (NifConvert crashes on nearly all Oblivion NIFs, but it works fine for most FO3 NIFs).
  • "Vertex groups" and "bone weights" are literally the exact same thing. You may not have known that if you've only ever used vertex groups as literal groups of vertices (like me), but vertex groups contain weight data.
  • Don't get too clever with collision data. If you try to put a compressed-vertices collision shape inside of a bhkListShape (to save on NiNodes), your NIF will crash Skyrim and the Creation Kit.