Working With Nifs 201 : Practical Use

From the Oblivion ConstructionSet Wiki
Revision as of 15:45, 19 February 2008 by imported>Qazaaq (typos lists, internal links etc.)
Jump to navigation Jump to search

Niffing 201, Practical use

So let's get to working with data! woo data party!

Some tips:

  • Elsewhere on the Wiki, you'll find guides to extract and from the .bsa archives. I suggest unpacking a bunch of these to something other than the oblivion\data folder, for reference. Personally, I have a meshes\ and textures\ sitting in my NifSkope folder. It always helps to have ready-made and working files to pull reference from, or to yank havok from, or just plain "how did they do THAT?" type of stuff.
  • When testing new effects, I find it easier to have a series of test files ready to go. Just stupid little junk meshes and textures already set for use in the CS. Whenever I need to try something out, I just edit the settings on one of these, and load up the game. Just saves time is all.
  • Don't know the difference between a face normal vs. a vertex normal? Maybe you don't even know what they are? Need tips on how to UV map? Look it up :) I've had to do a ton of research since I've first started, and can't possibly spill all of it in one guide, just too much. I really can't stress enough how much a little research can take you.
  • Check other guides for information on Havok! I only know the most basics, and generally try to avoid this area at all costs. (see also: I don't know enough to really write about it)


Node use and connections

A Node is a basic building block. It signifies a new branch in the structure, and can be thought of as a "container" for further nodes and data. A .nif always starts with Zero: the root Node. It also defines where the Center point that any other objects in that nif are based off. With Render>draw Nodes on, nodes are highlighted as you select them from the Block List, as well as a line drawn back towards the root node.

Each node has a number. In most cases, the actual numbering of blocks as you move down a hierarchy isn't important, just the manner in which they're linked together. More complex .nifs appear to jump back and forth with multiple connections.

Let's first examine the connections in a NiNode in Block Details:

  • Name: It can be named anything, but if you're copy/pasting between two files, the root node needs to have the same name.
  • Num Extra Data, Properties, and Children: This number defines how many of each type appears in each list. Whenever you need to connect something manually, adjust this number, and rClick on the appropriate list and Array>Update to refresh the list.
  • Extra Data, Properties and Children lists: These arrays, in order list the connections of each type. Double click an entry to edit it, or use -1 to clear an entry.
  • Collision Object: If your object needs collision, it attaches here.


A short Excercise:

For example, if you've copied the branch for a TriShape from one file, and just pasted it to yours:

  1. Click the root NiNode, and look down to Block Details.
  2. Edit Num Children to one number higher.
  3. rClick Children and Array>Update.
  4. Expand Children list, enter the number of the TriShape you just pasted, and hit enter.

Now the trishape you just pasted is included in the NiNodes hierarchy.

Also, we'd like to make the trishape we just pasted transparent, so let's add a property to it:

  1. rClick the TriShape, and do Node>Attach Property>NiAlphaProperty.
  2. The Property is added to the TriShape's hierarchy now.
  3. Click the TriShape, and expand Properties in its Block Details view, you can see the AlphaProperty attached there.

We can also just as easily remove the AlphaProperty, by rClicking on it, and do Block>Remove.

For another basic example, let's click on the TriShape's TexturingProperty, and Change the Apply mode. Double clicking on the value here brings up a list of available modes, change it to APPLY_HIGHLIGHT (the glass effect).


Textures

Since we're on the topic of textures, here goes: From a TriShape or TriStrip, a TexturingProperty is attached, which has a SourceTexture attached. I cover specifics of these properties in the breakdown guides.

To change a texture, you can either type the path in manually, or click the flower icon next to SourceTexture. If you set NifSkope's texture paths properly, you won't need to worry about proper pathing. By this, I mean the way Oblivion will look for the texture you've specified. Wherever on a person's hard drive they installed the game, Oblivion will declare a "base" folder from which it will work. For example, I have installed to:

c:\games\Oblivion\

Under the main Oblivion folder, is the data folder, where all the data files are. Oblivion declares c:\games\oblivion\data\ for a base. Any time it references a texture, it can just look in \textures\blahblah\texture.dds. Instead of

c:\games\oblivion\data\textures\blahblah\texture.dds.

Someone else may have:

c:\program files\bethesda softworks\oblivion\data\textures\blahblah\texture.dds.

Why make this distinction? If you don't have NifSkope configured properly, it will try to use

c:\games\oblivion\data\textures\blahblah\texture.dds

when you assign a new texture to a mesh, which will cause problems for the person in my second example. Render>Settings menu to assign your texture folders, if you haven't already. Always be in the habit of checking your texture paths if you are going to be distributing your mods.

Retex Troubleshooting is an excellent troubleshooting guide, please refer to that for other "my mesh is invisible/pink/black" issues.


let's do this!

Here are some basics for manipulating data in NifSkope to get nifty effects. I'll now roughly cover some of the basic tricks that I see get asked often. In many cases, coming up with an effect is up to you: I can detail on the various nodes and ways things can be attached, but actual implementation or configuration is yours to make. Again, there's hundreds of meshes shipped with Oblivion to take a look at for inspiration! Spend a little time looking around at how other files are constructed to give you an idea on how something works, or some small detail you may have missed when making your own.


Adding flames to a weapon

A simple cut/paste job! Nifskope won't render the particles, but will work with them just fine.

  1. Open some fire! I'd go with meshes\fire\firetorchlarge.nif, and expand the root node.
  2. rClick the billboardNode, and paste it into your weapons' .nif.
  3. Click the root NiNode, increment Num Children by 1.
  4. rClick Children, Array>Update.
  5. Enter the number for the newly-pasted billboard node into the empty spot on the children list.
  6. The billboard's mode is set to ROTATE_ABOUT_UP, which is perfect. The flame will always face the camera on the X axis, but follow the weapon around on Y axis.
  7. Expand the Billboard node, there's a node named EditorMarker- delete it by rClicking on it, and Block>Remove Branch. Also remove the DamageSphere node.
  8. The fire might not be the right size or in the right place. Be sure to do Render>display Nodes, so we can see where the base of the fire sits.
  9. rClick the billboard node, and do Transform>Edit. Using the XYZ transforms, move it to where you need it, and hit accept when done.
  10. Now rClick the billboard again, and do Transform Apply, so the settings stick when we save the file.
  11. Done.


Glass Effect

Many objects in Oblivion have a glassy appearance, enabling a model to use this is as simple as:

  1. Edit TexturingProperty's Apply Mode to apply_highlight.
  2. Edit the Material's Name to EnvMap2. (optional, I believe there are two methods.)
  3. Done.


Animating a texture

There is a more comprehensive guide to animations in general here. But here is a "from scratch" approach. Animated textures cannot be used on skinned armor, clothes, and bows. And I would imagine hair and the body won't accept it either.

There are two texture animation types: Transform or Flip. Transform animations move the texture around the UV mapping in various ways you can specify. Flips are a series of files (like that fire animation) that get played in a sequence.

Setup for either method:

  1. Can't use a normal map, having one present will prevent the animation (you might be able to get away with using a normal map, and vertex colors, it can be quirky). And remember, if you're not using a normal map, don't use a tangent space block.
  2. Go to your TriShape or TriStrip data, and edit "Has vertex colors" to Yes, then update the Vertex Color Array.
    1. Alternatively, just paint vertex colors in your 3d editor before exporting. We can use black/gray/white colors to control specularity via a SpecularProperty if desired.
  3. rClick your TriStrip/Shape, and add a VertexColorProperty. Set it's Flag to 40, Vert_mode_src_amb_dif, and light_mode_src_amb_dif.


Transform method:

  1. rClick your meshes' TexturingProperty, and do Block>Insert>T>TextureTransformController.
  2. Also, do Block>Insert>F>FloatInterpolator, and Block>Insert>F>FloatData.
  3. In TexturingProperty, edit "Controller" and enter the number for the new transform controller we just added.
  4. Expand Base Texture, change Has Texture Transform to Yes, then change Tiling X and Y to 1 and Transform Type to 1.
  5. Moving down to the Transform controller now, Edit the flags: Check Active, and Mode=Cycle.
    1. Frequency=1
    2. Stop Time=Whatever best suits the animation you'll be doing. Measured in seconds.
    3. Target - Edit this to link back to the texturingProperty that we attached this controller to.
    4. Interpolator=Enter the number of the niFloatInterpolator we added earlier.
    5. Operation: What kind of animation we're doing:
      1. ..0: scroll along U
      2. ..1: Scroll along V
      3. ..2: Rotate (you may need to tinker with Offset settings back in texturingProperty>Base Texture)
      4. ..3: Wierd zoom along U
      5. ..4: Similar wierd zoom along V

Currently, NifSkope kinda wierds out with rendering texture animations, but you can generally reset it by editing Tiling again.

  1. Moving on to FloatInterpolator now, all we need to do is edit "Data" to the number of the NiFloatData we added earlier.
  2. In FloatData, let's change Num Keys to 2 for now, and set them to Linear.
  3. rClick Keys, and Array>Update, and then expand out both keys.
    1. Set the second key to the Stop time you specified back in the transform controller, and give its "Value" a 1, and hit play.

You can add more keys, and play around with different values to your hearts content. You can also move from linear keys to quadratic, but I'm not too experienced in that field.


Flip Method:

No need to edit "Has Texture Transform", but you can if you want fine tuning. Again, we can't use normal maps in animation.

  1. rClick and do Block>Insert>F>NiFlipController. Also add
  2. Edit your TexturingProperties' Controller to include the number of this FlipController we just added.
    1. Flags=Active and Cycle
    2. Frequency=1
    3. Stop Time=Your choice!
    4. Target=The TexturingProperty that this FlipController is attached to.
    5. Interpolator=The NiFloatInterpolator we added earlier.
    6. Sources=As many as you have animated frames. If you have 10 frames, then enter 10 here. Also, the first Source should be the same source Texture that the base TexturingProperty uses. Array>Update on the Sources list
  3. Jump over to the FloatInterpolator, and edit Data to reflect the number of the FloatData we added earlier.
  1. To save a bit of clicking, rClick your SourceTexture, and copy it. Now paste it as many times as many frames you have.
  1. Add each one numerically to the source list in your flipcontroller. Then have a bit of fun renaming each one to use each of your animation frames. This is my favorite part. Whee.
  1. Now in FloatData, change the number of keys to the same number of Source images you're using. Also change Interpolation to Unkown_key, and update the key array.
  2. Expand out all the keys, Time is in seconds, where that key is used, and "Value" corresponds to each frame. Ex: Time along the keys= 0, .5, 1, 1.5. Value along the keys= 0,1,2,3. I set my stop time to 2, so the last frame has a .5 second time before the animation loops again.
  3. Hit play, adjust any timings you see fit, and enjoy!

I'll try to get some more minor-specific guides like this stuck here at a later point.


See Also

This guide is part of a series that I have written:

NifSkope Alchemy - This is my first guide, it's a little shorter and is a little quicker and easier to digest than the others.