Models are usually compiled into MDL files.
What are compiled MDL files?
Essentially due to this being a weird 2000's era engine compiled MDL essentially is actually a representation of the actual in-mem struct, with some pointers then hooked up after.
Compiled MDL files therefore can be translated back to MDL ASCII in most cases (newer NWN:EE model changes mean some older decompilers may not always work).
Why compile models and not leave them as ASCII?
MDL files can be binary or ASCII, so why not just leave them as ASCII?
Well the reason is speed - the game will have to dynamically compile (read the text/interpret it/output the right memory structure) for every ASCII file loaded by the game. This can be incredibly slow in complex scenarios and for frequently loaded or large models, especially since NWN:EE generates normals and tangents at runtime. Caching in NWN is almost non-existent (things unloaded due to going out of sight disappear from the cache very quickly) so any speed up of load times is beneficial overall.
There are also a few other reasons compiling may be a good idea:
- Strips out erroneous unnecessary fields
- Codifies default field values in a standard way
A lot of the models in BIF files are compiled for this reason, although may be decompiled with certain tools.
It is highly recommended to compile your models before releasing them to users via. nwsync, hakpacks or vault uploads. Even if the file size is ever so slightly larger due to mandatory fields and so forth, the benefit are worth it!
Debugging Crashing Models
So you've exported an MDL from Blender or Max and it's crashing in game as an ASCII model, well, you won't have much info from the NWN game itself annoyingly. Some common issues may be:
- Check your file and model name length (which should match and be all lowercase), it should be 16 characters or less
- Check any bitmap, texture0/1/2 and materialfile references are 16 characters or less. If they're missing that shouldn't cause a crash
- You could also change the references to an unused name so they don't get loaded and this helps test if you've got a buggy texture (eg; a bad DDS or TGA file)
- Check the setsupermodel line is set to a valid model name (again 16 character limit)
- Check that node names are not too long - 32 characters is the maximum length, and notably if two nodes have the same node name it can cause weirdness or crashes since it truncates longer names (eg; one node being my_node_name_really_long_name_00001 and one being my_node_name_really_long_name_00002 both end up as my_node_name_really_long_name_00 in the compiled model causing issues)
- Check all the nodes are parented correctly to other nodes in the model, and that there is a dummy node with the parent set to null
- Remove erroneous fields just in case; see Model Table of Parameters for a reasonable list of what can be ignored
- Check the models are not too large. There is around a 11K triangle limit for individual meshes. This is 2^15 / 3 (the max number of vertex indices assigned to a mesh is a signed 16 bit integer, 1 face requires 3 indices), resulting in the total of 10922 faces. It primarily is important for large tiles and placeables.
- If you are using skinmesh note:
- Bones being are tied to a skinmesh, but you can only have 64 of them in a single node. Models do support multiple skinmeshes however.
- There is also a maximum of 4 bones per vertex
How to Compile
There are a few ways to compile a MDL file, the main ones are using Console Commands which were included in NWN:EE and obviously is the most compatible (as in it is what the game is using). See that page for that information and Models page for further information on other options.