Hex Editing .nif Files
Tutorial by Sorcerer
Greetings, and welcome to my Hex editing tutorial. This will explain the workings of a hex editor and explain how you can use one to change the textures on your morrowind models and look at how you can use a shorter or longer filename without messing up the NIF file.
Before you start messing with the models I recommend taking a backup of them, just in case
What the hell is Hex anyway?
Most hex editors are split into two parts, a hex side and an ascii side.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | . . . . . . . . . . . . . . . .
I wont go very deep into the inner workings of hex, but if you see the line above, there are 16 double digits and 16 dots. those double zeroes are the hex value of the dot behind the line. So, for instance if we type a 1 to replace the third dot, the third hex value will change to the hex value of that 1. The same thing works the other way - if you insert the hex value, the appropriate character will appear on the line behind.
00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 | . . 1 . . . . . . . . . . . . .
Hex doesn't stop at 9, it goes all the way to F before adding another digit, so:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 - and so on
Okay now: how can we use this to our advantage? Well as you already should know, you can change the textures used in Morrowind's .nif files by hex editing the files and searching for the texture name. Most hex editors have a 'string search' button, set this to ascii and search for TX, and the program should take you to the proper location.
NOTE: look at the ascii values. Most of it is gibberish but some places you can see the occasional letter, other places you can see words.
The only thing we can really edit are those words.
You should see something like this:
TX_C_COMMONSHIRT_C_3C.bmp
If the filename is long it might be spread across more than one line, don't worry about that though.
Now just replace that with the texture file you want to change it to. Before you do though, read on.
Explaining the use of hex
The model file has a registry at the top, explaining to the program where it should look for stuff. For instance, the texture info starts at a certain string, and the model info starts at another. We can't actually change these values, so be sure not to remove or add any strings yet, it might mess up your nif file.
This means you need to use the EXACT number of letters in the new texture files as the old one
C _ C O M M O N S H I R T _ C _ 3 C
C _ C O M M O N S H I R T _ C _ 5 A
There is a workaround to this though. Have a look at what I did when I made my spidersilk armor:
C _ O M M O N S H I R T _ C 3 _ C
A _ S P I D E R S I L K _ S_ C - -
As you can see our name has two characters less than the old one. If we were to just remove those and load up the model we would get an error.
What we do instead is change those last two characters with null values. Look at the hex display side of your editor; if you select the space after the name you should see a [05] that's the one that indicates end of filename. If you have to edit the length of the filename, do it before this hex entry.
So, we replace the _ and C with null values [00]
Now for the other way; longer filenames.
If you for instance need two extra characters in your filename, find the [05] value after the name again and check the next two values. If these are [00] they are safe to change. So REMOVE the hex entry for those two completely (not sure on all hex editors but on mine its simply backspace). Now INSERT two hex values IN FRONT of the [05] this is VERY important.
So remember; delete behind [05] insert in front
Using this technique, replace all the texture files in the models with your own, and you should be good to go.
Hope that made at least a little sense. If you're still confused, feel free to mail me
Questions/Comments on this tutorial? Talk about it in our Forums.
Printer Friendly Version
site:http://www.gametuts.com/
[TUTORIAL] Hex Editing .nif Files
Moderators: Haplo, Lead Developers
[TUTORIAL] Hex Editing .nif Files
I said I would return and I may have been right. The past must stay in the past as agreed. If the core needs me or has a job for me just ask for now I watch and write.
Former Moderator of the Core.
Was once called the Sotha Sil of the core.
Former Moderator of the Core.
Was once called the Sotha Sil of the core.