Saturday, May 5, 2012

Creating New Life with the Expotron and Max, Part 1

Introduction


Whoever has the Expotron has the power to create new life over all of Neverwinter. Those without it must content themselves with molding flesh over old bones. Nevertheless, power without sufficient knowledge can lead one to countless pitfalls. That’s what happened to me when I tried to rig my hydra model. Considering that a hydra’s most fearsome trait is its many venomous heads, seeing it completely headless in game has been a source of much frustration for me.

I tried to search the Internet for solutions to my modeling problems, but the sites that Google found did not have the answers. Most of the top links that Google returned even included my own blog. Eventually, I figured out how to solve the problem through trial and error – lots of trials that yielded mostly errors. To keep myself from making the same mistakes in the future (and to finally get a useful link from Google), I wrote this tutorial. Hopefully, other NWN2 modders will find it useful as well.

This tutorial is primarily for 3D modelers who know how to make and texture a creature mesh but don’t know the workflow for getting it in Neverwinter Nights 2. It will explain the peculiarities of making new skeletons and animations for NWN2 models, especially those whose meshes are stored in separate MDB files. This tutorial will also show how to export all the creature meshes, skeletons, and animations for use in NWN2. Along the way, we will tackle naming conventions and unravel the mysteries of relevant 2DA files. The latter topic may be of interest to NWN2 modders who are not modelers but want to edit 2DA files to correctly put custom creature models in their modules.

The following software must be installed for this tutorial to be of full use to NWN2 modelers:

  • Neverwinter Nights 2 (with or without expansions)
  • Software for editing 2DA files; e.g., Notepad, Excel, or one of the free 2DA editors available at the Neverwinter Vault
  • 3DS Max 6, 7, or 8. No other version will do.
  • The Expotron plug-in that was used by Obsidian Entertainment for NWN2

Modders who are not modelers will only need NWN2 and 2DA-editing software and may want to refer only to my section on editing 2DA files.

It is assumed that the reader already has a creature model that would comprise no more than 6,000 triangles if all its quads were converted to tris. This poly count is the total from all meshes that make up the basic model – body, head, wings, and tail, but not including hair or armor accessories. The model should already have been UV mapped and preferably textured. Optionally, there may be one or two lower LOD (level-of-detail) versions of the mesh already made, but these are not necessary to follow the tutorial.

Before proceeding to the tutorial proper, we need to lay out some basic knowledge to prepare ourselves for what follows.

About Model Parts and Their Skeletons


Each mesh in NWN2 is stored as an MDB file. Not all meshes are animated, but the ones that are will have skeletons and animations stored as GR2 files. Each skeleton should be composed of no more than fifty-four bones, not counting facial bones that are animated only in cut scenes (the “f_” bones) and attachment points (the “ap_” bones, dummy objects to which other non-animating meshes or visual effects may attach themselves). Fifty-four bones isn’t a whole lot, especially for creatures with extra limbs or heads. Nevertheless, there are ways to overcome this limitation, as we shall soon see.

A skeleton is a set of bones arranged in a hierarchy, much like a pyramidal organization chart. At the top of the hierarchy is the root bone. For skeletons that animate the body mesh, the root bone is typically at the center of the pelvis, although it need not be, especially for creatures that don’t really have a pelvis. The NWN2 engine uses the root bone to calculate distances between the creature and other objects. Because other bones can emanate from the root bone in any direction, the root bone is generally just a tiny nub, unlike the long bones found in limbs and torsos.

A model is composed of one or more meshes. Simple creatures, such as the chicken in NWN2, are completely embodied in a single mesh. More complex creatures may be composed of a head mesh, a hair mesh, a body mesh, a wing mesh, a tail mesh, and zero or more armor/clothing accessories. Accessories do not need their own skeletons because they stick to the creature’s attachment points. The hair, head, and body share the same skeleton hierarchy. Wings and tails may have their own skeletons, each of which comprises as many as fifty-four bones. In fact, making creative use of wings and tails is how one can overcome the bone limit in the body’s skeleton. Just because a mesh is listed as a wing or tail model doesn’t mean it actually has to be a wing or tail. It can be any part of the creature that needs its own skeleton. My hydra model doesn’t have any wings, but because it needed more than fifty-four bones, I divided my model into two parts – the body mesh and the mesh for its heads and necks. I assigned the latter mesh to the wings slot to give it its own skeleton.

If you find yourself needing more bones than are allowed on a single mesh, you can divide your model into three meshes – the body and head, the cloak or wings, and the tail. Each of these can have its own skeleton consisting of no more than fifty-four bones. Be aware, however, that a model that is divided this way will never have its parts joined perfectly at the seams. While moving, some parts of the wings or tail may sink too deeply at times into the body or may separate far enough to form a small gap. This is unavoidable. The best that you can do is to try to keep the parts joined as well as you can when animating the creature. If you must divide your creature model, try to cut it in places where players are unlikely to look closely, if that is at all possible.

There is a slight gap in the red dragon's tail, but players will not notice it because they will be too busy worrying about the opposite end of the dragon.

Some models have their head stored in a separate MDB file from their body. The head and body share the same skeleton structure, however, so what advantage is there in keeping the head and body meshes in separate files? There are two reasons for wanting to do that:

  • To allow different heads to go on the same body. For creatures of the same species and gender, you may want to allow some variation in the creatures’ head appearance. This is done by creating two or more head meshes for the same creature.  For example, you can make a new lizardman head to make it look different from other lizardmen.
  • To assign different textures to the body and head. Each mesh can have its own set of textures – diffuse map, normal map, glow map, tint map, and even specular highlights. The latter allows you to set the gleam of the mesh. The shine of metal, for example, is brighter and more concentrated than that of skin. It makes sense to separate the fleshy head of an armored creature from its metal body to give them different textures.

If none of these reasons apply to your model, it may be best to keep the head and body in the same MDB file. Assuming that the head is welded to the body, this will keep the parts perfectly fused even when the model moves.

The above considerations may also apply to wings and tails. A creature’s wings and tail meshes may have variations in their appearance as well as textures and specular highlights that are different from its body.

Even though meshes of multi-part creatures are stored in separate MDB files, it is best to keep all the meshes of each creature in a single 3DS Max file. When animating the creature later, you will need all its meshes and skeletons together.

That’s it for now. In my next blog post, I will discuss what 2DA files are needed to bring new creature models to NWN2, which columns in these files are important, and what to put in them.

5 comments:

Eguintir Eligard said...

Yes this is definitely what we need; the A to Z of the nwn2 process, when assuming mesh building is already known (easily googled).

If you have any resources to share regarding 2d texturing (maybe just links, not a tutorial per say) on how we can make 2d textures in photo editing programs, that would be FANTASTIC. I still have no idea how people make realistic or at least decent looking skins and scales and clothing from the 2d(texturing) perspective. The 3d part seems abundantly easy to find resources for, and even animation has been easier to find.

All I know is when I do 2d, all I can think of is floodfilling patterns and adding little paint brush touches but they look like they were done in ms paint circa 1998.

Frank Perez said...

Eguintir, I don't know of any links on making good diffuse maps. I've been meaning to write one, but I won't get around to writing it until I finish this long tutorial on using 3DS Max and the Expotron. Maybe I can have the new tutorial out in a week or two.

Eguintir Eligard said...

all in good t ime of course. I actually found (contrary to the typical workflow, I think) that I want to texture last... I need to do the animations first to see if there is too much stretching going on and so forth, before accepting the final pelt seam setup, and then, the majestic process of creating the diffuse. Good show so far!

Nicotine Caffeine said...

I have a question about the separated meshes. I asked around, and it seems everyone has a different opinion on the matter. I wan to import a model which his meshes are all separated (eg chest, head, neck arms and so on). I can't fuse them, becouse textures are all separated and i can't make a 'bricolage' of 'em.
So can i simply select all meshes and then add all the bones of the nwn2 skeleton?
It works?

Frank Perez said...

@Nicotine Caffeine,

Sorry for the late reply. I only check this blog once in a while because hardly anyone leaves comments here anymore.

In answer to your question, I'd say that it is possible to create a model composed of separate meshes to some extent - head, hair, body, wings, and tail. The "wings" and "tail" meshes don't actually have to be wings and a tail, as I explained in this blog post, but they will need their own skeletons. You can also have separate accessory meshes for bracers, gloves, boots, helmets, etc. Note that in the appearance.2da entry for your creature, its BODY_TYPE has to be set to 1, as I explain in the next post in this series.

I'm guessing that you're trying to import a model that someone else made with separate meshes and texture maps. If you can make the model comply with what the NWN2 engine expects, it may be possible to import it.