Monday, May 7, 2012

Creating New Life with the Expotron and Max, Part 3: Naming Conventions

This is Part 3 of my tutorial on bringing new creatures to NWN2 using 3DS Max and the Expotron. Part 1 of this series may be found here.

Many NWN2 modelers are aware of the naming conventions that models are supposed to follow, but just how strictly must these conventions be adhered to? It turns out that in some cases, models will not appear in the game if they are not properly named. In other cases, the naming conventions are merely suggestions that may safely be ignored. In this installment of my tutorial on bringing new creature models into the game, I will explain naming conventions as they apply to creature models. By the end of this blog post, you will know when to follow the naming conventions to the letter, when it is safe to relax them, and whether it is all right to disregard the rules if it is safe to do so.

Let’s get capitalization out of the way first. None of the model, skeleton, or animation names is case-sensitive. The names “C_Hydra_CL_Body01” and “c_hydra_cl_body01” refer to the same model. If you really want to be a jerk about it, you could name a model “c_hYdRa_cL_bOdY01” and have the members of the NWN2 community speculating about your sanity. The game engine will understand all these to be the same thing regardless.

Another thing to get out of the way early on is the maximum length of mesh and skeleton names. These names may not be longer than thirty-two characters, including all the prefixes, suffixes, and model numbers that go into the name. File name extensions do not count toward this limit.

If you intend to create new heads, hair, cloaks, armor/clothing, or accessories for playable races, you must strictly follow the naming conventions detailed in the NWN2 Wiki. The only thing you can vary is the model number that appears as the last digit or two of the model name, and even then, you should make sure that it does not share the same number as any other Obsidian-created model of the same type. If you expect similar custom content to be used in a particular module or campaign, make sure that your model number is also different from theirs. Most likely, you won’t know what custom content will be used unless you are creating models for a specific module that will use other custom content. If such is the case, just focus on not clashing with Obsidian’s model numbers.

Regarding accessories, playable races are not the only ones who can use them. Other creatures can use them as well if you create accessories specifically for them. Like accessories for playable races, creature accessories are prefixed by “A_” (without the quotes), but instead of being followed by a two-letter race code and single-letter gender code, it is followed by whatever is listed in the NWN2_AccessoryType column for the creature in appearance.2da. For example, the King of Shadows (index number 586 in appearance.2da) has “L” under the NWN2_AccessoryType column. This means that the names of all his accessories must be prefixed by “A_L_,” followed by the appropriate body part and model number as detailed in the wiki entry on naming conventions. Hence, the left bracer model that the King of Shadows may wear is named “A_L_LBracer1.” If the King of Shadows had another left bracer model to choose from, it would be named “A_L_LBracer2.”

Another instance of strict naming rules is on how a creature’s body models are named. For a non-player creature, the prefix of its body model is found in its appearance.2da entry under the NWN2_Model_Body column. This prefix is followed by an underscore, followed by a two-letter code for the body’s material, followed by another underscore, the word “Body,” and the two-digit model number. The default material is always cloth, the code of which is “CL.” It doesn’t matter if the creature is an iron golem or a gelatinous cube. Its default body material is always “CL,” and its default model number is always “01.” Other material codes are only relevant for creating armored versions of the creature’s appearance. Apart from varying how the creature looks, the models by themselves have no in-game effect.

Let’s take the example of an orc, whose appearance.2da entry under the NWN2_Model_Body column is “c_orc.” Its default body would therefore be named “c_orc_cl_body01,” and it is this body model that shows up when a creature’s appearance is set in the toolset to “Orc.”

If the model has a head that is stored in a separate MDB file from its body, its prefix would be found in the NWN2_Model_Head column of its appearance.2da entry. Each head model would be named by this prefix followed by a two-digit model number, the default being “01.” The orc’s head model, for example, is listed in appearance.2da as “c_orc_head.” This means that its default head model would be “c_orc_head01.” If a creature does not have a separate head model, then the value of this column should be “****” (without the quotes). It isn’t necessary to have “_head” in the head model’s name. What is important is that the name uniquely identifies the head model.

Each mesh can have one or two lower LOD meshes.  Their names are similar to that of the mesh on which they are based, except that they have the suffixes “_L01” and “L02” appended to them. For example, a mesh named “c_hydra_cl_body01” may have a LOD mesh named “c_hydra_cl_body01_L01” and another named “c_hydra_cl_body01_L02.” It is recommended that the L01 mesh have about 65% of the original mesh’s polygons, and the L02 mesh about 40%. In the game, when creatures are far from the camera, the engine substitutes the original mesh with one of the LOD meshes to conserve computational resources.

The skeleton file that a body mesh will use is indicated in the NWN2_Skeleton_File column in the creature’s appearance.2da entry. The root bone in the skeleton hierarchy must also be given this name. All skeleton names must end with the suffix “_skel.” The game engine expects this of skeletons. Apart from that requirement, you can name a skeleton anything you like. By convention, a skeleton is prefixed with the NWN2_Model_Body name. Hence, an orc skeleton would be named “c_orc_skel.”

The skeleton file that the creature’s head will use is identified in the NWN2_Head_Skeleton column of its appearance.2da entry. If the head and body are in the same MDB file, the value of this column should be “****.” If the head and body are in separate files, however, you should identify the skeleton that the head uses, even if it is the same as the body. The values of NWN2_Skeleton_File and NWN2_Head_Skeleton may be the same, although they need not be. However, you would need separate GR2 files for the skeleton of each head variation, and the model number of these skeletons would have to correspond to the model number of each head.

Suppose, for example, that I created a chupacabra model with four head variations stored in the files “c_chupa_head01.mdb” to “c_chupa_head04.mdb.” If the creature’s entry under the NWN2_Head_Skeleton  column were “c_chupa,” its head models would need skeletons named “c_chupa01.gr2” to “c_chupa04.gr2.” Each of these skeletons would be structurally the same as that of the chupacabra’s body. It would have the same number of bones, which are named identically across all files, and these bones would follow the same hierarchy. The only difference in the bones, if any, would be in their position, rotational angle, and length to account for variations in features from one head to another. Even if the bones of the head models were exactly the same across all skeletons, the creature would still need separate GR2 files for each head. If I had only one head model named “c_chupa_head01.mdb,” its skeleton file would be “c_chupa01.gr2,” not “c_chupa.gr2.”

Models for wings and tails may be given any name, although by convention, wing models have “_wings” at the end of their names, and the names of tail models have “_tail” at the end. Skeletons for these meshes may also have any name as long as these names have the suffix “_skel.” By convention, however, wing models have “capewing_skel” at the end of their names, and tail models, “tail_skel.” For example, the heads of my hydra model are implemented as wings so I can get around the fifty-four bone limit for the skeletons of each mesh. I named the mesh “c_hydra_wings,” and its skeleton, “c_hydracapewing_skel.”

Even texture files follow a naming convention, although this is purely for the sake of readability. In general, diffuse maps have the same name as the model for which it is intended. For example, if my hydra’s body model were stored in the file “c_hydra_cl_body01.mdb,” its diffuse map would be named “c_hydra_cl_body01.dds.” Normal maps may have the same name, but with the suffix “_n” appended to it. Using my hydra example, the normal map would be named “c_hydra_cl_body01_n.dds.” Similarly, tint maps use the suffix “_t” and glow maps use the suffix “_i.” In truth, the game engine doesn’t care what you call your texture maps, but this naming convention helps identify what each map is for.

Notice that creature models are generally prefixed by “c_.” They are named this way by convention to make it easy to identify them as creatures as opposed to, say, placeables or armor accessories. You can actually refuse to follow this naming convention for whatever reason, and as long as you ensure that the rules for naming the creature’s body are strictly applied, your model can still appear in the game. For example, I could name the body model of my hydra “plc_hydra_cl_body01” if I really wanted to. Nevertheless, it is a good idea to apply the “c_” prefix to creature models to avoid confusing other NWN2 modders who want to use your models.

As we have seen, most naming conventions for non-player creature models are really just suggestions. Apart from the strict manner by which body models and armor accessories are named, there is a lot of leeway in naming one’s models. While one could relax the rules when they don’t have to be followed, I suggest that they be adhered to anyway if only to make meshes, skeletons, and textures easier to identify.

That’s all there is for naming conventions. In my next blog post in this series, I will discuss attachment points for creature skeletons – their names, position in the mesh, the usual bones to which they are attached, and their standard usage.

No comments: