Skip to content

v4.10.0

Choose a tag to compare

@github-actions github-actions released this 19 Oct 18:18
· 126 commits to main since this release
v4.10.0
faf1af3

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, ambient or shininess line, a mesh got 0 where the game writes 1, so it compiled black and dull. Lights without lightpriority, nDynamicType, affectdynamic, shadow or fadinglight now get the game's values (5, 1, 1, 1, 1). An animmesh without a shadow line now casts a shadow, and a walkmesh without a render line no longer renders.
  • Nodes without an orientation line 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.57 is a quarter turn about Z, and orientation 0 0 0 1 is 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 transparencyhint above 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++'s std::sort exactly, which cleanmodels now reproduces.
  • Supermodels: a node name the supermodel uses twice is told apart by its place in the tree. Before, hand under hips could get -1 because the supermodel also had a hand under arm.
  • 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 detonate line on an emitter is now compiled, with the column byte the game writes (0xff).
  • classification Tiles, Characters and Doors are not words the game reads: it compiles them as no classification, and so does cleanmodels now, with a warning. Effects is 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_only was read as ambientonly. 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.5abc is 1.5, 1.#INF is 1, 0x10 is 16) instead of being refused. An integer field takes the leading digits (2.9 is 2, where it used to round to 3), and TRUE/FALSE count 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 as position 1 2 is read as far as it goes instead of being ignored. NaN, infinity and out-of-range numbers are still refused.
  • parent is read only in lower case, as in the game, so a node whose only parent line is PARENT is 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_blured lost 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.