Weapons:Modeling

From NWN1 Custom Content Guide

Jump to: navigation, search

We are going to model our trident on the existing short spear weapon. Remember, it is generally easier to start from something you know and build your content from there. Where do I get the standard weapon models used in NWN? What about NWVault? Sorry. While you will find a few models on the vault that are NWN-ready, most are in other model formats. So, while they may look nice, they don’t work directly in the game.

So where do I go? That’s what NWN Explorer is for. The content is already stored in the NWN game, you just have to learn how to access it.

  1. Open up NWN Explorer.
  2. Select File | Open Neverwinter Nights.
  3. Use File | Open Neverwinter Nights to open the game files. You will use the File | Open… option later for opening individual custom content files. Don’t open the NWN .BIF files directly using File | Open… - if you do, NWN Explorer will not show all of the context information with each file.
  4. Click on the boxed ‘+’ sign beside NWN Main Data from the tree on the right.
HINT:
  • You should actually check NWN Overrides first – it contains official updates from Bioware (NWN Main Data is the original CD content – which may be out of date).
  • Only if your file is not in NWN Overrides should you get it from NWN Main Data. If you don't follow this simple rule, you risk undoing Bioware's bug fixes when you distribute your custom content.
  • Get the latest version of NWN Explorer to open the patch files and SoU content directly.

What you get is a listing of all of the core content files for NWN. Each BIF file (Binary Information File) is a packed file like the hakpaks we talked about earlier. They contain standard NWN content.

If you look through these you will find that the core NWN models are stored in two files:

data/models_01.bif 
contains the character and creature models
data/models_02.bif 
contains the armor/model pieces, placeable items, and weapon models

We will use data/models_02.bif because we want the weapon models.

Contents

[edit] Model Type

Scroll down, way down. What you want are the models that start with w.

Weapon models are named using the format: wxxyy_z_nnn. The prefix represents the model type for a weapon. The remainder of the name represents the weapon class and name for the model.

Image:Ccg fig 02.jpeg

[edit] Weapon Class and Name

After the w, the next four characters (wxxyy) describe the class and name of the weapon:

xx Model class
yy Model name abbreviation

For example, wplss_t_011 equates to:

w for weapon
pl for polearm
ss for short spear

We’ll get to the _t_011 part in a moment. First, here are the standard weapon resources for data/models_02.bif:

Table: models_02.bif
Type Class Name Maps to
W Weapon
AM Ammo
AR Arrow
BO Bolt
BU Bullet
DT Dart (I don’t think this is really valid because it does not appear in the baseitems.2da file).
AX Axe
BT Battle Axe (two-handed)
GR Great Axe
HN Hand Axe (one-handed)
BB ?
QS ?
BD ?
QS ?
BI ?
MI ?
BL Bludgeoning Weapons
CL Club
FH Flail, Heavy
FL Flail, Light
HL Hammer, Light
HW Hammer, War
ML Mace, Light
MS Morningstar
BW Bow
LC Longbow, Composite
LN Longbow
SC Shortbow, Composite
SL Sling
SH Shortbow
XH Crossbow, Heavy
XL Crossbow, Light
XR Crossbow, Repeating
DB Double-handed
AX Double Axe
MA Dire Mace
QS Quarterstaff
SW Two-bladed Sword
MG Magic
RD Rod
ST Staff
WN Wand
PL Polearm
HB Halberd
SC Scythe
SS Short Spear
SP Special
GA Gauntlet? (I don’t think this is really valid because it does not appear in the baseitems.2da file).
KA Kama
KA Kukri
NN Nunchuka (I don’t think this is really valid because it does not appear in the baseitems.2da file).
SC Sickle
SP  ? (I don’t think this is really valid because it does not appear in the baseitems.2da file).
SW Sword
BS Bastard Sword
DG Dagger
GS Great Sword
KA Katana
LS Longsword
RP Rapier
SC Scimitar
SS Shortsword
TH Throwing
AX Throwing Axe
DT Dart
SH Shuriken
WB ?
LC  ?


[edit] Position Code

Okay, sounds easy enough so far. But what are all those other numbers and letters I see in data/models_02.bif (the _t_011 stuff)?

We have already looked at how NWN represents the different components of a model by looking at the item properties under Appearance for a custom-created item. The options you choose correspond to the different model types in the data/models_02.bif file.

First is the position code. We know there are three position codes for each weapon:

t top
m middle
b bottom

So in the earlier example, wplss_t_011 equates to the top piece (the head) of the short spear.


[edit] Model ID

There is a specific format for the id as well: nnz. There are two characteristics:

nn Model (although I’ve not seen the first character anything other than zero and I have had trouble getting past 09)
z Color/Texture (right now the ones typically supported are 1 = metal, 2 = brass, 3 = wood) but you can add your own

So in the earlier example, wplss_t_011 equates to the first model # and the initial color (usually metal, followed by bronze/brass/gold, followed by wood) of the top piece of the short spear.


[edit] Special Models

Now you understand the weapon models and their naming conventions. Well, almost. What about some of those other models with names like waxbt_fxacid? There are special purpose models for special effects:

_mb The motion blur model
_fxacid, ect. special effects (acid, etc.) – shows the game engine where to render the colored mist or flames that envelop different models
_blur Ignore this model type. This looks like it is another type of motion blur model but it is not. It is not used for anything and is a vestigial model left from earlier game development days
_000 Ignore this model type as well. It looks like a normal weapon model but it is not valid. It is a vestigial model left from earlier game development days as well

So waxbt_fxacid shows the model for a weapon, an axe, in fact a battle axe, corresponding to the effect you would get if that battle axe were magically enchanted to drip acid.

There are a few weapons (e.g., the bullet) that do not have the full 3 parts. These are represented with a format of wxxyy_nnn. Just exclude the Position Code.


[edit] Part 3: Creating the 3D Model

HINT:
  • Start with a model you know works. There are models for swords, spears, even a flail with a chain linking head to handle. Use this model to understand how big to make your objects and where to place them.
  • Complex models with lots of polygons will slow down combat considerably. How many is too many? Well, it varies. I created Wave with 157 vertices. This is pushing the high end of what you want. Many of the standard NWN models have less than 50 vertices. I would aim for 30-40 per model file. The CEP puts a ceiling of 300 polys for the entire weapon (all three parts).
  • If you would like your object to have a chrome finish, you do not have to texture it. Otherwise, figure out UVW mapping and do your own texturing.
  • The default weapon texture is w_metal_tex.tga. The texture image is comprised of blocks of textures, some alpha masked, some not. If you use an alpha mask texture on a weapon then where it is transparent the underlying shiny value will show through.
  • The gmax and 3ds max export scripts are a bit funky working directly with a blocked texture file like w_metal_tex.tga. You need a single texture file for the entire object or you need to do a proper UVW map.
  • If the NWN MDL Tool pane does not come up and you can’t find the scripts to load, you probably don’t have the scripts installed. See the link at the end of this document to get a copy. Put the .ms files in your gmax\scripts\startup folder.
  • You can only export editable mesh objects. So if you model with shapes or nurbs you must convert to an editable mesh before exporting.
  • Collapse your objects to editable meshes before applying any NWN modifiers.
HINT:
  • Size matters.
  • 1cm in game = 1 max unit. If this is too confusing you can import another model that is properly scaled.
  • Because NWN uses a tiny scale, the import export tool lets you import at a magnified scale of 100X magnification. It will then export at -100X to get it back to original size.
HINT:
  • This cutting and pasting thing from the listener is a bit annoying. You can get a utility from NWVault <STB: insert link here> that does this for you automagically.
  • You must close and re-open the Aurora toolset whenever you add something to the /override directory. The game and toolset only look at and load files from the /override directory once, upon start-up. If you do not re-open the toolset, it will not recognize any new resources.

So with all of that in mind, I am going to create my models for a trident. If I look at the spear models, the first thing I see is that the standard shaft (m as in middle) and end (b as in bottom) models for a spear work just fine for a trident. So I’m just going to create a new model for the head of the spear (t as in top). Here are the basic steps using gmax. Directions may vary according to your software.

  1. Open NWN Explorer.
  2. Select File | Open Neverwinter Nights.
  3. Select data/models_02.bif from NWN Main Data.
  4. Scroll down and select the model wplss_t_031.mdl.
  5. Right click on the row and select Export.
  6. Save the file to a new directory. This is a binary model file. You cannot easily open or read it in binary format.
  7. Open a command prompt window.
  8. Run NWNMdlComp –d wplss_t_031 on the binary model file to convert it to an ASCII model file (it should have the name wplss_t_031.mdl.ascii).
  9. Open gmax. The NWN MDL Tool pane should automatically open on the left side. If it does not, load it manually using Maxscripts | Run Script…
  10. Load the spear model into gmax by opening the Import MDL sub-menu in this pane (not the File | Import… function) and using the Browse pushbutton to select the ASCII file you created in step 6.
  11. You can minimize the MDL window after you open the file. Take a close look at the model you loaded. Note the relative size and position of the model. This is important because the relative orientation and offset of your model now will be used when the game engine renders your weapon in three pieces. The reason your spearhead is not centered at the origin (0, 0, 0) of the gmax space is because it must be far enough out to rest comfortably on the tip of the spear’s shaft model (the middle piece). You must keep it there; otherwise it will not appear to be attached to the rest of the weapon when the game engine assembles the three models later.
  12. Note the base item. This is used by the import/export scripts to link special attributes to models (animations, etc.). The spearhead is a child mesh of the base. Don’t change the name of the model for now, or of the base (this is important for now – we will change it for later models). The spearhead model has a name of wplss_t_031.
  13. Now modify the standard spearhead or replace it with your trident model (read the tutorials for gmax to see how to actually create 3D models).
  14. If you created a new model, be sure to link it to the base item as a child object.
  15. Open the Export MDL sub-menu of the NWN MDL Tools pane. Select Export MDL.
  16. Wait? Where is my exported file? It didn’t even ask for a filename. The gmax import/export utility does not have the ability to write files. What it does is dump an ASCII version of your model to the MAXScript Listener. What you need to do is open MAXScript | Listener… and then copy and paste the listing into a text file. Save it as wplss_t_031.mdl<tt> and you are done.
  17. Copy your <tt>wplss_t_031.mdl file to the /override directory of your game installation. If you used a .tga file as a texture, put it in the same directory.
  18. Open up the Aurora Toolset. If it was still open from before, save and close the module and toolset first then re-open it.
  19. Open your Weapon Tutorial module.
  20. Select the Area you created, and then the Item icon on the right toolbar (it looks like a sword).
  21. Choose the Custom tab.
  22. Your original spear should be under the Weapons, Polearms category.
  23. Right click Trident and then select Edit from the pop-up menu.
  24. Select the Appearance Tab.
  25. Select Top model 3 if it was not already selected. I also chose the Bottom model 4 (one of the default models) because I like the bladed end better than the rounded model #1. And I made the shaft gold (color 2).
  26. Click OK and then save your module.

Image:Ccg fig 07.jpeg

This is what you get when you look at your spear. It is starting to shape up. There are a couple of problems with this model that say we aren’t done.

  • Note the picture on the right side – it still looks like a spear with a default spearhead! Where is our trident? We need to create a 2D weapon icon to fix this.
  • Now all basic spears using model 3 will look like tridents because we have overridden the default spear model. We need to change a few more things to fix this problem as well.
  • Our trident is actually a spear. It will work fine this way but we may want to actually add an entirely new weapon, a trident, rather than piggy-backing on the spear forever.
  • "FIller for the end of section note"
Note on ResetXforms:

Have you ever opened up one of your creations in NWN and found it does not look like what you saw in your modeling tool? Too big? Too small? Parts blown out of proportion or disappearing? Sounds like you have a problem with advanced transforms. This subject is so frequently discussed and so problematic I thought I would pull it out into its own flagged section. Let me start by discussing why you need to care about resetting transforms.

Gmax and 3ds Max can hold information about your object (whether or not parts of it are mirrored, which directions normals really point, how it is scaled and rotated, etc.) that is not exported with your model in a way that NWN can understand or use. What this means is that what you see in Max may not be the same as what you see in NWN.

For example, objects can be transformed (scaled, rotated or moved) either in world space or in sub-object space. Transforms in sub-object space take place when you transform vertices, edges, faces, polys or elements of an object (or all of them at the same time). Transforms in world space take place by selecting your object at the highest level and transforming it.

What this means is that if you rotate an object in world space, it will not be rotated when you export it to the game. Or moved (transformed).Let me repeat that in different words because this part is key: Bioware's NWN engine does not read world space transforms!

As you can imagine, this might be a huge problem. One way to fix this problem is to do all of your transforms at the sub-object level. However, this is only a partial solution because the same problem occurs with other operations as well (for example, mirroring objects often inverts the direction of their normals or faces).

The good news is that there is a way around it. In Gmax or 3dsMax you can do a ResetXform operation on all the pieces of your model and then collapse each of these modifiers onto your editable mesh. By doing this, you are turning this complex transformation information into something simpler that NWN can understand. In practical terms it means what you see in Max and what you see in NWN are more likely to be the same.

ResetXform can be found on the Utilities panel. Use the ResetXform utility to push object Rotation and Scale values onto the Modifier Stack display and align object pivot points and bounding boxes with the World coordinate system. Reset Transform removes all Rotation and Scale values from selected objects and places those transforms in an XForm modifier (no, really, it will). You can then collapse the modifier into your object and away you go.

Some notes on ResetXform:

  • Sometimes after you do a ResetXform you may need to clean up parts of your model. For example, often on mirrored objects doing a ResetXform will expose the fact that your normals are really inverted. You will need to flip the normals on the mirrored part after you are done. These aren't things that ResetXforms breaks - they are things that would have been wonky in the game and it is showing them to you early.
  • You can also reset the transforms on the Pivot block of the Hierarchy panel. It will convert your world space transform into a sub-object space level transform. However, it will not fix problems like reversed normals so the Utility panel is generally the way to go.
  • You must do all of these things before linking your object to other objects (like the Aurabase). Why? Because the ResetXform modifier affects child objects as well the parent. If your objects are linked together they will inherit transforms and scaling. By resetting you are only really resetting them relative to the parent objects.

So let me summarize: if your object appears differently in the game than it did in 3dsmax or gmax you probably forgot to reset the transforms on it. Make sure your object is unlinked and then use ResetXforms on the Utility Panel to clean it up before proceeding.

Personal tools