Working With Nifs 201 : Meshes, Data, and you

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Meshes, Their Data, and You[edit | edit source]

Many of you will be working with meshes, so here's a practical guide for doing so. I also offer troubleshooting steps throughout this guide.

Starting with the hierarchy, we have the root node. Depending on what type of model we're working towards, be it a piece of architecture, armor, a weapon, etc, it will be attached as a child to this node.

The root node also needs to have some extra data attached. Prn and BSX flags are common.


On BSX Flags: I'm not on my home computer, so I can't fact-check at the moment. This flag defines some basic properties on how Oblivion will handle a few things. Animation and Collision are two of the flags. Nifskope 0.9.7 introduced a clickable Flag icon, which allows easy editing of the flag in plain english. If you have animated a mesh, for example, you may need to return here to enable animation, or else it will not play the animation in-game.


Prn: This data defines which node on an actor to attach, if no skindata is present.


Shields: Bip01 L ForearmTwist

For Hair Bip01Head

One-Handed weapons: SideWeapon

Bows and Two-Handed weapons: BackWeapon

Torches and similar: Torch

Lots of idleobjects for special animations seem to just use "Weapon" Bip01 R Hhand or Bip01 L hand.


For objects that will be in the world on their own, we also have a UPB Data block. It seems to be extra havok data, extra renderer instructions and other optimizer settings. I've not fully researched these blocks. Generally easiest to copy one from a file that has a similar use. Weapon, shield, building, etc. One notable exception, is billboard nodes, define a custom billboard method through their PRN attachment.

Next, are havok blocks, Again, look up another guide, as whenever possible, I just copy/paste some working havok blocks here and edit them to suit.


niTriShape and niTriStrip[edit | edit source]

These two nodes signal the start of a mesh in the hierarchy.

Block details for a shape node are basically the same as a regular niNode. Flags should be set to Continue, and you can rename it as you please. (Has Shader has no apparent use for oblivion). Here you can link Data, Extra Data, Properties, and a skinInstance block.


Shapes are straight-up polymeshes: They define the structuring of the mesh to be rendered.


Strips are similar, but triangles are ordered into strips of triangles.No real noticable visible difference, except that strips get rendered differently, and more optimal. If you go into wireframe view in Oblivion you will see odd triangles and lines jumping all over, especially on architecture geometry. The stripping process will create invisible triangles to disconnected strips to ensure one big stream, and that is what you see.

- Strip a mesh when you can. In some cases, usually when going heavy on properties or other effects, shapes may be better off. Your call. Instead of typing out shape/strip every time, just know that from here on in, i'm just going to use Shape to mean either.


-rClicking on a TriShape node gives you the option to Mesh>Strippify. On a triStrip, you get Mesh>Triangulate. -If you are pasting a mesh over another, they need to be of the same type; You can't paste a triStripsData over a triShapeData to replace it.


-Properties are directly attached by rClick-ing a shape, and do Node>Attach Property. This automatically links the newly created property in the appropriate slot. We also have:


Mesh>Prune Redundant Triangles: Not sure on the exacts here. Likely to be useful in cleaning a troubled mesh, or covering for modelling oversights? I assume that it removes same-space triangles.

Mesh>Remove Duplicate Vertices: Some smoothing methods duplicate vertices in-place. These won't be used in oblivion, in lieu of vertex normals. This removes the extra ones. Optimize!

Mesh>Remove Unused Vertices: Another troubleshooting attempt, for cleaning off unused vertices.


Mesh>Face/Smooth Normals: I cover the nature of normals shortly, but you can re-seat normals back to their face position, and then Smooth them. Actual smoothing depends the mesh and how it is constructed. you need to Update Tangent Space after altering the normals this way.

Mesh>Update Tangent Space: I try and cover this a few blocks down. This updates or creates tangent space for the mesh, and places this data into a BinaryExtraData block attached to the shape. This step is needed for nearly every mesh for the game.


Texture>Export Template: This will export a wireframe .tga image of the UV mapping for the selected shape. If you are doing retextures for a mesh, This is your friend! UV coordinates define what parts of the texture file correspond to which parts of a mesh.

.OBJ Export: Exports the selected shape to .obj format, with a .mtl sidecar for material settings. .OBJ Import: Select an .obj file to import over the selected mesh, overwriting it.


I should note that the Spells menu has import/export multi modes. These differ in that nifskope will then im/export all the meshes from the .nif to a single .obj.

On the subject of injecting meshes and it's importance[edit | edit source]

Currently, we only have exporters for Blender, Maya and 3ds max. Many other modelling applications can be used, many of those can export to .obj (see manuals or plugins for details) to inject into a nif file. The only two big limitations are: .objs can't have vertex colors, or oblivion's specific SkinData, used for rigging to skeletons. -BUT- In some cases, exporting a skinned mesh via .obj can work well to your advantage!

Clothes/armor/body parts, and heads have data for skinning, but you can make changes in a 3d app without having to re-do all this. The .obj format will maintain Vertex Order when going back and forth. You can safely make changes to a shape, and put it back into the .nif with no messing around with skinning.

<<important>> By maintaining vertex order, I mean that you cannot do any action that would change this order. One can scale, move, and rotate, but not weld or separate.


Example: You're merging two pieces of armor, but the pauldrons clip the breastplate, and you wish they didn't.


-rClick the shape for the pauldrons, and OBJ>Export. Do the same for the breastplate shape, so you have reference to work with, or make changes to the breastplate if needed.

-Import these into your 3d app. (refer to manual)

-Use the tools available there to move the pauldrons into the desired shape. Don't forget to Apply the transformations and clear node history (if used) when you're done.

-If you only changed the pauldrons, export those back out to .obj.

-Back in nifskope, rClick the pauldron's triShape, and do .OBJ>Import. Nifskope will give a warning about .obj not having skindata, but that's ok, we're professionals. (The trishape already has our skindata, we just moved the vertices, so the skining work stil applies)

-Again, if you edited the breastplate too, import that over the breastplates' triShape.


If all went well, your changes should be apparent in the render view! If any triangles are stretched way out or otherwise distorting, then you lost vertex order during modelling. Somewhere along the way, you (or the 3d app) did something to alter the order, weld, separate, cleanups, inserting or deleting faces, edges or verts, polysmooth, extrude, bevel, chamfer and so on: These all add or remove vertices from the mesh and cannot be used for this excersize.


It may be possible that your 3d app is messing it up for you. Make a scanthrough of the import/export options available for doing .objs for possible clues. Some apps have an option to auto-weld everything when importing, which is obviously a problem.


big tip: Check these things first before spending hours doing real work! Once you get the .obj into your app, export it right away without making any changes; and take it back into nifskope- This will let you know right off if you need to examine program-specific settings.

Another limitation to think about is how the mesh was skinned. The pauldrons were likely rigged to use the neck, top of the spine, clavicles and upper arms. If you were to move the pauldrons down to be used as a belt and check it out in-game, you'd find that they sit where you put them, but will still move as if attached to the shoulders. Raise your arm to cast a spell, and half your belt moves up quite dramatically.


Shape and Strip Data[edit | edit source]

This is the actual meat of a mesh, it's attached to the parent shape via the "Data" value.

-rClicking the triShapeData in the block list also yields an option to flip the UVs, used in the case of an exporter that exported flipped uv mappings. I can't say i've ever seen this be the case, however.

-We also have Mesh>Update Center/Radius. In some cases, the radius was miscalculated during export. In-game, these meshes will "dissapear" if they aren't very close to the center of the screen. Use this option to correct it!


Num Vertices: Defines how many vertices are used in the Vertex list. (if you change this number, you'll have to make a change to "normals" to see a change in current Nifskope) Has Vertices: y/n. kinda obvious :) If you're having export problems, this might be something to look at.

Selecting the Vertices array in block details to display them in the render view. Selecting an indivudual from the list highlights it. Coordinates in XYZ can also be edited.


You can rClick the Vertices list and do "Normalize", but I can't think of a proper example of using this.

Num UV Sets 2: I'm not aware of any oblivion meshes that use more than one UV set, but this would assumedly define how many sets of UV configs to use.

UV Sets: The big array of UV coordinates. Again, UVs are the part of the mesh that tell the renderer which portions of the texture to use. The 3d mesh exists here in 2d, and the modeller unwraps these uv "shells" to prep the model for texturing. This is useful to check to see if it exists or not for troubleshooting. (In some cases, the UV coordinates were never exported from the 3d app, which will need correcting before moving on.)


Center/Radius: Defines the center of the shape. Radius is similar. These are used by the engine to determine when or when not to render something. When a mesh is completely offscreen, for example.

Has Vertex Colors: y/n. Turning this on (if it was off) will default all values to white. (array>update on the Vertex Color list to make the change, as usual) (you may also need to select one of the vertices, hit a color and accept right away for nifskope to render properly.)

Vertex Colors: The big array of vert colors! As with the other arrays here, selecting the list will display the points on the mesh, and selecting an individual highlights it in the Render View. You can edit values by hand, or use the Color Wheel Icon.

A VertexColorProperty also needs to be attached to the shape for these to be used. Use the mode "amb_dif" for both values, with a flag "40"

Vertex colors are used in a wild number of ways in Oblivion. Foremost, for shading! I think grass meshes use vert colors to control how much they sway, for example. Vert colors can be set to be emissive, control specularity, mask off portions (hair shader), control/refine special effects, control alpha transparency, and a lot more I'm sure.


Many meshes in Oblivion were pre-lit, or vert-painted by hand in their 3d apps.to give the effect of being pre-lit. Load up just about any piece of architecture, and turn off texture rendering to see what I'm talking about.(Render>Settings>show textures) The vertexColorProperties for these meshes are set to amb_src_dif Ambient/Diffuse.


They've used a nifty occlusion method to define shadows on many of their meshes. Doing this to your mesh can really make it pop out by adding the impression of shadows at no cost to the games performance! I've taken to doing it by hand. I pick a near black, low gray, high gray, and white. I flood my mesh with white, and start painting in the shadows. No need to get really fancy here, the spacing of your vertexes will handle the blending for you. Plus, you only really need to add shadows to crevices to give the depth effect.


You can also do this automatically, try looking up guides for setting up Ambient Occlusion, baking, or prelighting for your 3d app.

The new meshes released with Shivering Isles really showcases the effect well: In particular, the gromite weapons, and any of the architecture! Load some up, and try turning Vertex Colors on/off to see the difference.


Has Normals: y/n. Useful for troubleshooting.

Normals: XYZ rotations for each normal. Also, clicking on the Normals list will cause Nifskope to render the normals, and selecting an individual from the list will highlight that normal on the mesh. They appear as lines leading away from their sources. If you have problems with some faces being backwards, you will see that the normals point in the opposite direction (from the desired direction, that is.)


Each vertex has a "Normal". Normals define how light reacts to the mesh. By default, vert normals are "set to face" - They point away from the polygon perpendiclarly. When viewing this polygon straight on, it will show the most light. As you rotate this polygon, it reflects less light to you, to help determine the "depth" of the scene. Also, having all normals set to face results in hard, chiselled edges between every polygon- the kind of thing we associate with older-model low-poly 3d graphics.


We can give the model a smoother look by altering each vertex normal. If we need to fix this in nifskope, you can do rClick>Mesh>Smooth Normals. This is an operation usually easier done in a 3d modelling app, where greater control over what gets smoothed is available. This method applies smoothing to the entire shape up to the maximum smoothing angle (default is 60 degrees). This works fine for most objects where the only edges that need to retain their "hardness" are greater than 60 degrees. Object that have edges that need to remain hard that are less than the smoothing angle need those edges to be unwelded. [Say you have a knife blade where the seam between the sharpened edge and the blade's core is 12 degrees, but you want that seam to remain hard (visible). If the vertices along the seam are welded together, the visible seam will be removed by the smoothing process. If the vertices are unwelded, so the faces are free-floating from each other, but still in the same positions, the visible seam will not be removed. You can create a set of free-floating faces in Blender by selecting the faces, pressing 'Y', and clicking to Ok the split. You can use smoothing groups in 3ds Max].


Also on a related note, Bethesda's creatures are excellent examples of how normals and normal maps can really bring a model into shape. Check out any of their fleshy beasts, use Render>Settings to turn on/off the normal map shading to see the model without a normal map applied. The shading becomes very apparent.


The Extra Data[edit | edit source]

BinaryExtraData, which is generated by rClicking on the trishape node, and doing Mesh>Update Tangent Space. This data block is needed for rendering the mesh, and is the base for which the normal maps bend the normals. Clicking on this data block will cause nifskope to display the vertex normals for your mesh. When making a new mesh, The first thing I do in nifskope, is do the tangent space, apply a flat gray texture, which has a flat normal map (which has a white alpha channel). Then I Set the material settings to nearly black, except I crank specular up to white. (If the object appears too dark, you can temporarily reduce the glossiness in the material properties and/or uncheck Textures in the Render Settings). Rotating the model around, I can easily check that all my normals are in the right direction. If you have an ugly seam, that causes a diamond pattern, or a zig-zaggy non-smooth face, check with the normals view on. You'll probably see that normals are bent crookedy. This can be caused by overlapping UVs, or duplicated vertices. To get a smooth normal here, you can do the following in your 3d editor and export again: Make sure the offending vertices are joined. In some cases, flipped UVs will cause the seams. This can be fixed by unwrapping the uvs fully, or by splitting the vertices along the seam, and then re-averaging the resulting normals. (this may not be the best advice, but it works.)


If you are feeling adventurous, check the Normals array in the ShapeData. Highlighting any normal in the list will also highlight it in the render view. use the arrow keys to go down through the list until you hit the offendor, and edit the value by hand until satisfied.


Triangles: Lists all the triangle connections. yup.


For a triStrip, The data works more or less the same for us, except now we don't have triangles. Instead, we have:

Num Strips: Shows you how many strips the shape is made up of. This was generated by the stripper code.

Strip Lengths: How many points are in each strip.

Has Points: y/n, should be yes already, nifskope did it for you if you stripped a trishape.

'Points: From nifskope: "The points in the triangle strips. Size is the sum of all entries in Strip Lengths."

We also have an option to rClick the triStrip, and Mesh>Unstitch Strips. I think this will separate the strips into smaller ones with no sophistication. I'll take a stab that these new strips are direct-connetion alone, with nothing created to attach one strip to another.

I don't know if this is a better optmization than having a single strip.



Miscellany[edit | edit source]

Most .nifs can have multiple shapes in them, and I recommend doing so. Each shape can only have one material and one texture affecting it, which is one reason for using multiple shapes. For many effects, architecture, and some armors, you may need to use more than one texture. Again, keep in mind, that the numbering of a node is something to pay attention to. Two trishapes using the same texturingProperty will both reference the same numbered property. You will have to change one to use a different one, this is done easy by Spells>Optimize>Unique Properties. Conversely, you can re-use properties between different shapes. Say you've rClicked on a shape, Node>Attach Property>NiAlphaProperty to your first shape. You could then go do your second shape, Edit the Properties list - Increment it by one. Update the property array, and then enter the node number for the alphaProperty to link it. Now both shapes share the same alpha property.

If you have a large number of disconnected shapes that need to share properties, it may be best to use them in an array. Ex: I had rigged up a sword that used 7 small billboards each act as a seperate "light" effect. I started a new BillboardNode attached to the root node, and attached the alphaProperty right to this new node. In this case, all the meshes, being children of a node that had alpha transparency on it, behaved with transparency.


Texturing and Materials[edit | edit source]

I've covered both these in more detail in the Breakdown section, so please check there for more information.


Many weapons also feature a sheath that sits on the characters' side at all times, and the weapon is put into it when sheathed. This is done by having a second NiNode attached to the root node. It has been renamed to "Scb" This "Scb" node has the mesh for the sheath attached to it. The game engine uses this node to attach the sheath portion to the appropriate place on the actor who has the item equipped.


Many effects or other low-visibility have a node named "EditorMarker" Which has a square mesh attached. This is to make selecting and moving these objects in the Construction set possible. Anything attached to these nodes (should) not not be rendered in-game.


And I think that's a wrap for now. Further explorations may be added from here on.


see also[edit | edit source]

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

Working With Nifs 101 : An Introduction

Working With Nifs 101 : Basic Use

Working With Nifs 101 : Copy and Paste

Working With Nifs 201 : Meshes, Data, and you

Working With Nifs 201 : Practical Use

Working With Nifs 301 : A Checklist

Working With Nifs 301 : Nodes Breakdown

Working With Nifs 301 : Properties Breakdown

Working With Nifs 401 : Particles!


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