Weapons:Modeling
From NWN1 Custom Content Guide
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.
- Open up NWN Explorer.
- Select File | Open Neverwinter Nights.
- 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.
- Click on the boxed ‘+’ sign beside NWN Main Data from the tree on the right.
|
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.
[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:
| 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
|
|
|
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.
- Open NWN Explorer.
- Select File | Open Neverwinter Nights.
- Select data/models_02.bif from NWN Main Data.
- Scroll down and select the model wplss_t_031.mdl.
- Right click on the row and select Export.
- Save the file to a new directory. This is a binary model file. You cannot easily open or read it in binary format.
- Open a command prompt window.
- 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).
- 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…
- 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.
- 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.
- 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.
- 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).
- If you created a new model, be sure to link it to the base item as a child object.
- Open the Export MDL sub-menu of the NWN MDL Tools pane. Select Export MDL.
- 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.
- 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.
- Open up the Aurora Toolset. If it was still open from before, save and close the module and toolset first then re-open it.
- Open your Weapon Tutorial module.
- Select the Area you created, and then the Item icon on the right toolbar (it looks like a sword).
- Choose the Custom tab.
- Your original spear should be under the Weapons, Polearms category.
- Right click Trident and then select Edit from the pop-up menu.
- Select the Appearance Tab.
- 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).
- Click OK and then save your module.
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:
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. |
