1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[TUT] Using NIF Viewer to edit units (long)

Discussion in 'Civ4 - Modding Tutorials & Reference' started by Rabbit, White, Mar 17, 2006.

  1. Editing units with NIF (Scene) Viewer - Link to PDF version

    Introduction

    The NIF Viewer that comes with the 3ds max plugins (SceneViewer.exe) allows you not only to view the files but also to edit them a little – you can remove or add objects, and you can change some of their properties. While limited at first glance, with a little bit of creativity you can create a lot of variations of units, and if you have even the most basic 3ds max skills then there are even more possibilities (just check out the units in my sig).

    In this tutorial I will go over how to edit units using the NIF viewer, in particular how to remove and add stuff and how to give one unit a weapon from another unit. All the things I talk about I learned by trial and error working with the viewer, which means that there is probably tons of stuff missing, so if you know something I don’t, or have discovered a better way to do something, don’t hesitate to post about it. Also, while in this tutorial I primarily deal with the civ4 units, all these things can be applied when adding object that you created yourself in 3ds max.

    A word about terminology. A unit is the complete civ4 unit. A model is the primary “actor” in that unit – the guy holding a sword, riding a horse, etc. A mesh or an object is any additional part of the unit that is not part of the model (but rather attached to it), e.g. sword, rifle, shield, quiver in some cases, etc.

    Finally, this is a fairly detailed tutorial (I want to cover as many potential questions as possible :)), but it’s not necessarily basic. For example, I'm assuming that you’re familiar in general with Civ4 modding.

    Preparation

    Download the 3ds max plugins, if you have 3ds max 6 or 7+ then download the appropriate version and unzip directly into max’s root directory. If you don’t have 3ds max then download any version and unzip wherever.

    Once unzipped find the files BoundShape.nif and BoundShape.tga. For any unit you wish to open in the NIF viewer you will need to have these two files in the same folder as that unit (for convenience you can copy these two files into all the unit folders in the civ4 installation directory).

    UPDATE: If you get a missing MFC71.DLL dll error, just google it. The first link points to a site where you can download it with isntructions on where to put it.

    Ok, now we can start messing with files…

    NIF Viewer’s interface

    Make a copy of the swordsman unit. It’s easiest to just make a copy of the entire swordsman folder into your project directory but strictly speaking you only need the two [unitname].nif and [unitname]_fx.nif files (swordsman.nif and swordsman_fx.nif in this case) and all the textures. The KF and KFM files are animations, which we can’t do anything with using the NIF Viewer, so they’re not needed. Open the NIF viewer and open the swordsman.nif file.

    Ok, the most important part of the interface is the scene graph tree on the right. This is where you do all your unit modifications. It’s a hierarchical representation of the unit with all of its components. It’s composed of two types of nodes – NiNodes, which I will refer to as nodes, and NiTriShapes (and in some cases NiTriStripes), which I will refer to as shapes. The shapes are the actual physical objects in the units – weapon, piece of equipment, the model itself. The nodes are more versatile – they act as containers for shapes, as dummy objects to mark attachment points on bones, and some contain information that allows the unit to use outside resources, such as sounds. Both nodes and shapes have information about their position and orientation, both relative and absolute. Finally, while nodes can contain shapes and other nodes, shapes cannot contain anything.



    There is also the scene graph list, which allows you to quickly find the necessary objects (instead of opening every branch in the tree), as well as texture and performance statistics, which are useful but are not needed for this tutorial.

    Figuring out what you can do

    Since the most basic thing that you’ll use the viewer for (besides viewing :)) is to remove objects, you need to know what exactly you can remove. Go into selection mode (the mouse cursor button at the top) and click one of the swordsman’s swords (try saying that five times fast), you will notice that the tree opened up and has the sword’s shape selected. Now click the shield, same thing. Now, click the shoulder pads – notice that the shape selected is the swordsman himself. In fact, if you search through the entire tree you will not find a shape for the shoulder pads. That means that the shoulder pads are part of the model and cannot be removed. If you really want them gone you’ll have to recreate the unit from scratch.

    So, you can only remove or add things that are separate shapes. Anything that’s part of the model itself cannot be removed or replaced. Other than recreating the model, the best you can do is cover that up with something else, but that’s not always appropriate.

    Removing the Swordsman’s shield

    I don’t know why but people don’t seem to like the shield, I guess they want the swordsman to suffer more :), so we’ll remove it. It’s literally a three click process. Click on the shield to select it. Go to the scene graph tree (tree from now on) and right click on either the Swordsman_Shield node, or the shape that is contained in it. Click on remove. Done. Now all you have to do is save.

    In this particular case you could’ve remove either the node or the shape, however make note that it’s not always appropriate to remove the parent node of a shape (i.e. you should only remove the shape). Sometimes, the parent node will contain other shapes or nodes, but even when it doesn’t, it might contain some information necessary for correct functioning of the unit. If you get into the habit of removing the nodes instead of the shapes and notice that something weird is happening with your latest unit then the first thing to do is try to only remove the shape and not its parent node.

    Adding objects from other units

    Ok, let’s give the swordsman a different sword, say from a knight. While the swordsman is open, click the add file button and load up knight.nif. Side note: When merging objects from two different files I usually prefer to match the files, i.e. to swordsman.nif add sword from knight.nif, and to swordsman_fx.nif add sword from knight_fx.nif. I don’t know how necessary it is but it doesn’t cost you anything. :)

    After you added the knight to swordsman you will see both models together. Go into selection mode, and click the knight’s sword and then the swordsman’s sword. This will open up the tree to display both swords. Select the knight’s sword (in the tree), click and drag it to the Swordsman_Sword node, and drop it. Now you have both swords in the swordsman hand and you no longer need the knight. Remove the NiNode “knight.nif” node.



    You will notice that the knight’s sword isn’t properly oriented in the swordsman’s hand. This will be a common result when moving objects from one unit to another. To fix it we’ll need to adjust the sword’s orientation and perhaps position. Right-click on the sword in the tree and click properties. This opens up the properties dialog, the tab we’re interested in is the second one, entitled Local Transforms. This is where we can adjust object’s orientation, position and scale. The orientation is the most complicated one as it is represented by a rotation matrix. Here’s a good place to learn more about rotation matrices.

    In our case, in order to properly orient and position the sword, we will need to rotate it 180 degrees around the X-axis (refer to the image to see what are the values in the matrix for that) and position it at coordinates (0, 14, 0). Once you’re satisfied with the new sword’s position and orientation you can remove the old one (I usually use the old weapon to help me figure out the proper position for the new one), and save the file.



    You might’ve noticed that the new sword leans back a bit when compared to the old one. In general, little differences like that will not be detectable in game but if you want you can adjust angles like that as well, it just involves sine and cosine functions :). I find that whenever I move something between vanilla units, 90 or 180 degree rotation around one of the axis is enough, and if you’re adding your own object you can adjust those (little) angles in 3ds max.

    Before using this unit in game you should make the exact same changes in the swordsman_fx.nif files. I always modify both files when I’m making my units. The good thing is that the changes are exactly the same for both files, so when you’re working on the first file, record the values you used for orientation, position and anything else, and then repeat them for the other file.

    Finally, don’t forget to add whatever textures are used by the new object to the folder where the new unit is in. In this case it’s knight_128.dds, sometimes you might also need to copy the gloss texture as well.

    Now you can just copy both nif files and the textures into art/units/swordsman folder and see it in action.

    Conclusion

    Well, that’s all there is to it - fairly simple. All we did was give the swordsman a different sword but there’s much more that can be done. Obviously if you have some experience with 3ds max you can create alternative weapons or just objects to add to units – helmets, armor, equipment etc. You’re also not limited to only replacing non-animated objects, because in some cases the animations used are just simple combinations of rotations and translations (same as a sword swinging during attack animation).

    For example planes use such simple animations for their missions – if you replace the plane model from one of the vanilla units with your plane, it will get the proper animations, effects and sounds associated with planes. You can even replace propellers with your own or just use the propellers from vanilla planes with your plane models (i.e. replace vanilla plane with your own model and re-position the propeller from their plane to match yours) and have a fully animated plane without doing a single animation. :) If you want to know more about that refer to the second part of my Exporting models from 3DS MAX into Civ IV tutorial, and really, replacing a the entire plane is not much different than replacing a sword, the only trick is to find the proper node to which attach the new mesh.

    Note: The above mentioned method of replacing the entire plane only works with planes, and to an extent with ships and tanks. It will not work with other units. For example, you can't put the maceman's model instead of the rifleman's model so that maceman uses rifleman's animations.

    Well anyway, I hope this tutorial was helpful. Feel free to post any questions about the tutorial or the topic in general.

    Cheers :)

    I've posted the second part of this tutorial with more about rotation matrices and object properties.
     
  2. Dual

    Dual Gun Mage

    Joined:
    Mar 28, 2005
    Messages:
    492
    Location:
    The Gateway to the West
    Good tutorial, and good work figuring all that out on your own. :thumbsup:

    Now I'm going to have to go through all the vanilla units and see what can be edited in each one. :) There must be a lot of possibilities with a little bit of imagination.
     
  3. Ploeperpengel

    Ploeperpengel academic precarity

    Joined:
    Feb 2, 2006
    Messages:
    4,748
    Location:
    Berlin
    Now where was this mentioned? Can't recall exactly, something like "give a man a fish and you'll feed him for a day teach him how to fish and you'll feed him for a life time"?
    Did you ever think of applying this to your sig ? You should do it now you've earned it: :santa2:
     
  4. Thanks guys.

    Btw, let me know (and this goes out to everyone :)) if there are some areas of the tutorial where you feel I didn't provide enough detail, or maybe something that wasn't covered but you feel that it should be (within the constraints of the tutorial of course).

    Also, what is your opinion on me releasing a bunch of objects (weapons, helmets, pads) as nif files so that the community can just add them to whatever they want?
     
  5. Cafegio

    Cafegio Warlord

    Joined:
    Sep 1, 2005
    Messages:
    177
    Why does it say : Cant find shader or cant find tciv4 skinning gloss
     
  6. (I also included your question from the other thread since it's more appropriate here)

    I'm not sure about the shader error but the pink sword and shield mean that you didn't copy the swordsman's textures to the same folder where you're creating the new unit. So, if you're giving warrior swordsman's shield and sword, copy the file swordsman_128.dds to whereever that new warrior is.

    I don't know about that "upper half/lower half of the body" problem, can you describe it in more detail - where does only half the body shows up, in nif viewer in game? What were you trying to do with the unit that had that problem, give it new weapon, remove something from it?
     
  7. seZereth

    seZereth FfH´s art monk(ey)

    Joined:
    Feb 3, 2006
    Messages:
    3,900
    Location:
    Bayreuth
    nice, could have used this tutorial some days before i learnt most by trial and error ;) BUT now some more people can go on creating "models". hope that there will be some creativity out there.

    And YES ! ! !! ! do that stuff Nif, give me a Feather i can attach to a helmet or hat, give me a renaissance hat, give me a cool helmet, armorpieces, and what would be real usefull, some sort of Troll/Goblin/Gremlin ears, which stick out from the head to make all those creatures which werent possible by now, or some sort of spikes, which could be attached to the back of a monster or armor, and all that stuff. that can create a variety of different models, to make the civ4 world even richer!
    you would be our Chief, our Creator, our supplier, without you we cant do new stuff :) so take the chance and start an avalanche! everyone will know without you that wouldnt have been possible.

    Do it, baby. and to woodelf, now you have your chance to attach your moonhelmet and oxygenpack to any unit by yourself !

    Give it a go! START THE REVOLUTION ;)
     
  8. Ploeperpengel

    Ploeperpengel academic precarity

    Joined:
    Feb 2, 2006
    Messages:
    4,748
    Location:
    Berlin

    Yes please! this is most wanted and I like to add don't forget new fashion details cloaks, dresses etc.:bounce:
     
  9. J_Period

    J_Period gone :(

    Joined:
    Feb 8, 2006
    Messages:
    385
    Location:
    Denver, CO, USA
    oops, didn't notice this when I made this thread
    well you know what they say about brilliant minds ;)

    Some stuff I would personally like for my mod(cuz I'm selfish :D):
    An extension to the skirts of primitive warriors to make 'em almost go to the ground
    Elven Helms
    Elven Greatswords
    Battle Standards
    Horns (and other instoments)
    A Cape
    Feathers!
    See:
    Also:
    A Mohawk
    A Dwarven Beard
    (now you can't tell me they aren't cool-well maybe you can if you're not a nerd like me :p)
    Finally:
    A less braided, more "natural" dwarven beard


    I swear I really have tried making my own models, but I am seriously 3ds-handicapped!

    C'mon warhammer fans, you gotta pressure rabbit :D He's done so much for us, that we have a right to demand more (that was sarcasm BTW) We don't just want human civs do we? (heh I really wanna do some high elves...)

    If you fulfill theese demands I shall have more for you! (or anyone else who can get 3d modelling to work :crazyeye:)
     
  10. Ploeperpengel

    Ploeperpengel academic precarity

    Joined:
    Feb 2, 2006
    Messages:
    4,748
    Location:
    Berlin
    Hm maybe I'm too stupid for this program. But could you include some hints on other functions of the viewer in this tutorial if they are included. I for instance would simply like to have more light and can't find the button to switch it on:mischief:
     
  11. To add more light open the "Default Node" that contains a camera and two lights, open the properties of the first light and modify the RGB values of the ambient color. Now, I haven't tested it but you might want to restore them to black before you save the unit, just in cases it messes it up in game.
     
  12. I just discovered a whole new bunch of things that can be done in the viewer. Give me a few days and I'll update the tutorial. :)
     
  13. Ploeperpengel

    Ploeperpengel academic precarity

    Joined:
    Feb 2, 2006
    Messages:
    4,748
    Location:
    Berlin
    thx for the tip rabbit.

    Edit: also looking forward to see what more you cast out of this hat :salute:
     
  14. seZereth

    seZereth FfH´s art monk(ey)

    Joined:
    Feb 3, 2006
    Messages:
    3,900
    Location:
    Bayreuth

    i found out some things too ;) am doing some beasts and fantasystuff, just by modifiing properties and so ;)
    But i hope you discover some more things, my "dragon" does wierd things... and i think he could use some "animated" wings
     
  15. J_Period

    J_Period gone :(

    Joined:
    Feb 8, 2006
    Messages:
    385
    Location:
    Denver, CO, USA
    anyone else having problems with the viewer crashing frequently? :( Especially when I try and save...

    (not the dll error btw)
     
  16. Ploeperpengel

    Ploeperpengel academic precarity

    Joined:
    Feb 2, 2006
    Messages:
    4,748
    Location:
    Berlin
    You really meant that serious?! Dragon?:eek:
     
  17. Not frequently but the viewer is definitely unstable. Sometimes it would crash if I drag a mesh to another node, other times during saves. :(
     
  18. J_Period

    J_Period gone :(

    Joined:
    Feb 8, 2006
    Messages:
    385
    Location:
    Denver, CO, USA
    Hmm, that sucks...every time I save, it crashes and gives me a log...I wanna see how my polar bear rider looks in game!
     
  19. Wow wow, hold your horses there! You put a rider on a bear?! That's probably what causing the crash. It doesn't work, you can't move around the actual units, just various objects that are attached to them. I tried once putting a cavalry on a keshik's horse - I figured, both riders, both on horses, the same horses in fact with the same biped node names, it's gotta work right. Well it didn't, it crashed on me. I guess there's only so far we can go with unit mod's in the nif viewer. :)
     
  20. J_Period

    J_Period gone :(

    Joined:
    Feb 8, 2006
    Messages:
    385
    Location:
    Denver, CO, USA
    oh :p it seemed so simple ;)
    I'll experiment more when I get home...
    thanks
     

Share This Page