Nif Tools and the Nif File Format Knowledge Base

Post » Mon Jan 21, 2013 6:48 am

Welcome, this is an attempt at a comprehensive documentation of the .nif file structure and how to manipulate it with Nifscope, Nifconvert and Chunk Merge. The Nif Tools wiki has only this listed "Information on the structure of Nif files needed". Apparently no one has ever laid it out and I learned everything I know from dissecting OB and FO3 meshes.

This information will be specific to the Skyrim version and will contain more than just the structure layout(potential wiki article). I will need help filling in what I don't know so please share and i will compile it. As It stands i will be able to say nothing of rigging. Hopefully we can get a nice outline that can be posted to the wiki. Thank you.


Nif Tools

http://niftools.sourceforge.net/wiki/NifSkope
https://github.com/skyfox69/NifUtils/downloadsNif Convert .1.54 Chunk Merge .1.55

Tutorials

http://niftools.sourceforge.net/wiki/Skyrim/Adding_Collision_Mesh_using_ChunkMerge this tutorial uses nifs that were exported from max or blender 2.49b. An alternative method will be outlined here.


Nif Structure Simple Outline

Every Skyrim nif file contains at the min the following:
  • Header This conatins a list all of the node(block) types, a list of all of the nodes(blocks) and a list of string data pertaining to each node
  • BSFadeNode This is the root node(always 0) and parents all of the orphan and parent nodes contained in the file.
  • BSXFlags This node tells the engine what type of mesh the file is.
  • NiTriShape This node parents the geometry and allows manipulation of that geometry such as translation(moving) and scale(resizing).
  • NiTriShapeData This contains the actual geometry of the above block including all vertices, triangles, normals, tangents, bitangents and vertex colors.
  • BSLightingShaderProperty This node is always a child property of a shape and tell the engine which textures the shape should use and how light reacts to it in game.
  • Footer This simply points back to the root node(0)
Currently The BSFadeNode and BSlightingShaderProperty nodes are not fully decoded and can not be created from scratch. When creating new meshs you will always need to start with an existing Skyrim valid mesh.

More general info will be added here soon....
User avatar
Richus Dude
 
Posts: 3381
Joined: Fri Jun 16, 2006 1:17 am

Post » Mon Jan 21, 2013 12:31 pm

The following post contains a comprehensive list and explanation of each node type and the data contained in them. Nifscope 1.1.3 is being reffered to when describing the behaviors of these nodes. All descriptions are written implicitly to the best of my knowledge. Unknowns are not listed. If any part of this is wrong to the best of your knowledge (or even better broad consensus) please inform me and I will make the appropriate changes.

Legend:
xx.xx = standard constant default value
> = expandable property
abc123 = refrence to other node or property
abc123 = Important


Header
  • Header String -- This contains the nif file format indentifier and version #
  • Version -- Current version for Skyrim is 20.2.0.7
  • User Version -- Curent version for Skyrim is 12
  • Num Blocks -- This the nomber of nodes contained in the file
  • User Version 2 -- Curent version for Skyrim is 83
  • >Export Info -- Expands to display 3 strings, 1 for creator and 2 for descriptors
  • >Block Types -- List of each type of node found in the file
  • >Block Type Index - Index list of each node found in the file
  • >Block Size -- Index list of byte size per node
  • Num Strings -- This is the number of strings and can be altered to shorten or lengthen the string array. Double click the value to change.
  • Max String Length -- This number correspondes to the longest character length string. This should fill itself appropriately when the array is updated.
  • >Strings -- The name of each node is stored here and should you want to change any of the names of your nodes it should be done here. Double clicking a node or it's name under it's details allows you to enter a number coresponding to this array. It can be done in the tranform edit dialog for most nodes but it's not reccomended because each letter you type will add a new string to this array. Also each time you import a shape the current node name will be overwritten and a new string will be created. Though it does not seem to make a difference to the game engine if this array is bloated with garbage, it's good practice to keep it tidy in order to maintain as small a file as possible. Right click to update after changing the Num Strings. Entries are deleted recursivly from last to first.

BSFadeNode -- This is the root node of ALL skyrim meshes and they are only valid with the presence of this node. This node cannot be created from scratch so you must use one created by Bethesda.
  • Name -- This is the data found in the Header strings array and is always the first entry, 0
  • >Extra Data List -- This always points to the BSXFlags node but can also point to other nodes like INV. See full list in next node description
  • Controller -- If the mesh is animated then this will point to the NiControllerManager
  • Flags -- The Skyrim engine doesn't use this anymore. This number is always 14
  • Translation -- With x,y,z coordinates you can move all shapes within the mesh in unison. Applying the translation will transfer it the to all of the children nodes except the bhkCollisionObject. The application will be additive to any existing translation on those children rather than overriding. The engine ignores this data so it is only useful when manipulating the geometry.
  • Rotation -- With y,p,r degree values you can rotate all shapes within the mesh in unison. Applying the rotation will transfer it the to all of the children nodes except the bhkCollisionObject. The application will be additive to any existing rotation on those children rather than overriding. The engine ignores this data so it is only useful when manipulating the geometry.
  • Scale -- With %(1=100%) you can resize all shapes within the mesh in unison. Applying the scale will transfer it the to all of the children nodes except the bhkCollisionObject. The application will be additive to any existing scale on those children rather than overriding. The engine ignores this data so it is only useful when manipulating the geometry.
  • Collision Object -- Applies only to shapes that are direct decendants of this node. When multiple collision objects are used shapes are parented to different NiNodes and seperate collision objects to each of those nodes.
  • Num Children -- determines array size of the following property.
  • >Children -- This array lists all of the NiNode and NiTriShapes parented to this root node.
  • Num Effects -- n/a
  • >Effects -- n/a
User avatar
Melissa De Thomasis
 
Posts: 3412
Joined: Tue Feb 27, 2007 6:52 pm

Post » Mon Jan 21, 2013 7:11 pm

This post reserved for manipulation method explanation.

This a WIP and i need to take a short break.. more to come...
User avatar
Krystal Wilson
 
Posts: 3450
Joined: Wed Jan 17, 2007 9:40 am


Return to V - Skyrim