Repository navigation
v4.10.0
cleanmodels v4.10.0
This release compiles, parses and decompiles models the way the game's own compiler does, checked against its output. The checks come from a new conformance suite: small test models, each compiled by the game itself (nwmain-linux compilemodel), with the expected result spelled out. cleanmodels v4.9.0 matched the game on 7 of its 46 compile tests; this release matches all 46, and all 46 decompile tests. Each change below comes with the engine code or game compile that shows it.
Animmesh animations play correctly
The game stores an animmesh's animation frames vertex by vertex: every frame of vertex 0, then every frame of vertex 1. The ASCII lists them frame by frame. cleanmodels copied the ASCII order straight into the binary, so every animmesh compiled by cleanmodels played scrambled in game, and decompiling a game binary wrote its frames back in the wrong order. Both directions now follow the game, including vertices split by their texture coordinates.
Compiled models now match the game's compile
- Defaults for lines a model leaves out. Without a
diffuse,ambientorshininessline, a mesh got 0 where the game writes 1, so it compiled black and dull. Lights withoutlightpriority,nDynamicType,affectdynamic,shadoworfadinglightnow get the game's values (5, 1, 1, 1, 1). An animmesh without ashadowline now casts a shadow, and a walkmesh without arenderline no longer renders. - Nodes without an
orientationline got a malformed rotation (a quaternion of length 0.88). They now get the identity. - Orientation axes are normalised as the game does it:
orientation 0 0 2 1.57is a quarter turn about Z, andorientation 0 0 0 1is a 1-radian turn about X, not no turn. - Node numbers follow the order nodes are declared in the file, not tree order.
- Child order: where a node has a child mesh with
transparencyhintabove 0, its children are sorted the way the game sorts them, non-meshes first and then meshes by hint. Past 16 children that is libstdc++'sstd::sortexactly, which cleanmodels now reproduces. - Supermodels: a node name the supermodel uses twice is told apart by its place in the tree. Before,
handunderhipscould get -1 because the supermodel also had ahandunderarm. - Key lists on geometry nodes (
alphakey,alphabezierkey, … outside an animation) were dropped without a word. The game keeps the first key, and so does cleanmodels now. - A bare
detonateline on an emitter is now compiled, with the column byte the game writes (0xff). classification Tiles,CharactersandDoorsare not words the game reads: it compiles them as no classification, and so does cleanmodels now, with a warning.Effectsis one of the game's words and still works.
Reading ASCII the way the game reads it
These change what some hand-edited models compile to. Each comes with a warning naming the line.
- Unknown keywords are ignored, as the game ignores them. cleanmodels used to guess the keyword you meant and apply it. A typo such as
setfillumcolor(common in NWmax exports) gave self-illumination that the game itself never shows;ambient_onlywas read asambientonly. The warning now names the likely intended keyword:"setfillumcolor" is not a keyword the game reads, so the line is ignored, as in the game; did you mean "selfillumcolor"?. - Numbers are read as the game's C library reads them. A value with junk after it keeps its leading number (
1.5abcis 1.5,1.#INFis 1,0x10is 16) instead of being refused. An integer field takes the leading digits (2.9is 2, where it used to round to 3), andTRUE/FALSEcount as integers. A vector line or list row stops at the first bad value, and the values after it keep their defaults; a short line such asposition 1 2is read as far as it goes instead of being ignored. NaN, infinity and out-of-range numbers are still refused. parentis read only in lower case, as in the game, so a node whose only parent line isPARENTis left out of the model. Other structural words written in upper case (NODE,ENDNODE, …) are still read, with a warning that the game would not read them.
Decompile fixes
- Controllers are read by their column count, as the game applies them. A one-column position controller holds only x; cleanmodels used to read two more floats after it, which belong to nothing, or to the next controller. Controllers the game skips (a column count other than 1, 3 or 4) are dropped with a warning.
- Detonate keys are read whatever their column byte (stock
vwp_flash_bluredlost them). - Short skin headers: in some BioWare and EE files, a bone's entry in the bone list lies past the end of the header. One such entry made cleanmodels leave every bone of stock
tni_udoor_19's curtains unnamed. The bone is now named from the skin's bone map, with a warning.
Checking
A new test compiles 22 of the conformance suite's models and compares the result with the game's own compile of each. The Python port carries every change and was checked against the Go build on all 32,832 game models: decompile, parse and compile give the same bytes and warnings. NWMAIN_FINDINGS.md has the evidence for each change (findings 38 to 50).
Not checked in game: the animmesh fix and the child order are worth a look on screen.