Guides/05

Meshes and materials

Read and edit Fallout 4 mesh files and material files.

esx reads Fallout 4 meshes (NIF) and materials (BGSM and BGEM). In a mesh it edits names, paths, node transforms, connect points and furniture markers. In a material it edits each field. esx nif export writes a model file from a mesh, and esx nif import makes a mesh from a model file: a new mesh, or a mesh that exists with the geometry of the model. The two commands read and write the skin of a shape, with its bones and weights. esx does not make collision, and it does not paint bone weights: a modelling program does that.

Each command that writes a file needs -o. Add --dry-run to see the result and write nothing. To read a file from an archive, extract it first with esx resource extract.

Read a mesh

esx nif show Gun.nif
esx nif show Gun.nif --asset-kind texture

nif show lists the blocks, the fields that esx can edit and the arrays that can get or lose an entry. --asset-kind shows the fields of one kind only. The kinds are texture, material and mesh.

A field has a path, for example blocks/0/NiNode/Name. The edit commands take these paths.

Read the geometry

esx nif shapes AxisBlock.nif
esx nif shapes AxisBlock.nif --shape 'Body:0' --vertices
esx nif shapes AxisBlock.nif --verify

nif shapes decodes the shape blocks and the skin blocks of a mesh. It writes no file. The report has three lists:

List Content
nodes Each node block with its name, its parent and its local translation, rotation and scale.
shapes Each shape block. The table below gives the fields.
connect_points The parent points with their transforms, and the names of the child points.

parent is the block index of the parent node. root is the block index of the root node, or null when the root of the file is not a node. rotation has the 9 values of the matrix in the order of the field Transform/Rotation of nif set.

A shape has these fields:

Field Content
vertices, triangles The two counts of the block.
vertex_flags The parts of a vertex: vertex, uv, uv2, normal, tangent, colors, skinned, land, eye, instance.
precision half for 16 bit positions, full for 32 bit positions.
vertex_size The bytes of one vertex in the file.
data inline, or none for a shape with a data size of 0. The geometry of such a shape is in another block, and its arrays are empty.
bounds The center and the radius of the bounding sphere.
shader null, or the block, the block type and the material path of the shader.
textures The texture paths of the texture set, or of an effect shader.
alpha null, or the block, the flags and the threshold of the alpha property.
skin null, or the skin block, the bone data block and the name of each bone.
segments null, or the count of segments, the total with the subsegments and the path of the SSF file.

This is the first shape of a mesh with two shapes:

{"block": 2, "kind": "BSTriShape", "name": "Body:0", "parent": 0,
 "vertices": 4, "triangles": 2, "vertex_flags": ["vertex", "uv", "normal", "tangent", "colors"],
 "precision": "half", "vertex_size": 24, "data": "inline",
 "bounds": {"center": [1.0, 2.0, 0.0], "radius": 2.2360680103302},
 "shader": {"block": 3, "kind": "BSLightingShaderProperty", "material": "Materials/EsxTest/AxisBlock.bgsm"},
 "textures": ["Textures/EsxTest/AxisBlock_d.dds", "Textures/EsxTest/AxisBlock_n.dds"],
 "alpha": {"block": 5, "flags": 4845, "threshold": 128}, "skin": null, "segments": null,
 "translation": [0.0, 0.0, 1.0], "rotation": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0], "scale": 1.0}

--shape NAME keeps the shapes with this name. Repeat it for more names. A name that the mesh does not have gives exit code 3 and the list of the names.

--vertices adds the decoded arrays to each shape: positions, normals, tangents, bitangents, uvs, colors, weights, bones and triangle_list. An array that the vertex flags do not have is null. The values are in the space of the shape, in game units: X to the right, Y forward, Z up. V is down in a UV. A tangent is the direction in which V grows, and a bitangent is the direction in which U grows. A triangle has three vertex indices and is counterclockwise from outside.

--verify decodes each shape block and each skin block, encodes it again and compares the bytes:

"verify": {"blocks": 2, "equal": 2, "different": []}

A different block gives exit code 7. Then error.details has the report, and different lists each block with the offset of its first different byte or with the error of the decoder. Each of the 862,499 shape blocks and skin blocks of the 159,866 vanilla meshes came back with equal bytes.

Change fields

nif set changes one field, or many fields in one call:

esx nif set Gun.nif blocks/0/NiNode/Name MyReceiver -o Fixed.nif
esx nif set Gun.nif \
  --edit 'blocks/9/BSShaderTextureSet/Textures/0=Textures/Gun/Gun_d.dds' \
  --edit 'blocks/9/BSShaderTextureSet/Textures/1=Textures/Gun/Gun_n.dds' -o Fixed.nif

--edit splits at the first =. --edits FILE takes a JSON list of {"field": ..., "value": ...} objects. Text fields take the text as you give it. Other fields take JSON: a vector is [x, y, z] and a quaternion is [w, x, y, z]. If one edit fails, esx writes no file.

nif set-paths changes path fields by rule. Use it when many fields have the same incorrect folder name:

esx nif set-paths Gun.nif --replace 'textures/OldMod/=textures/NewMod/' --asset-kind texture -o Fixed.nif --dry-run

Each --replace FROM=TO rule replaces FROM with TO in each path field, or in the fields of the --asset-kind that you give. FROM ignores letter case, and / and \ are equal. esx writes TO as you give it. The report lists each changed field with its value before and after.

Connect points

A connect point is the place where a weapon part or a workshop object attaches.

esx nif connect-points Receiver.nif
esx nif connect-points Receiver.nif --copy-from Donor.nif -o Receiver-new.nif --dry-run

Without --copy-from, the command lists the points of a node. With it, the command copies the points of the other mesh and makes the blocks that are missing. The copy keeps the parent names and the local transforms of the donor. Use a donor with the same layout, and check both meshes first. --source-node and --target-node select a node that is not the root.

nif insert adds one entry to an array, and nif remove removes one. nif show gives the array path and the fields of an entry:

esx nif insert Receiver.nif 'blocks/3/BSConnectPoint::Parents/Connect Points' \
  '{"Parent": "", "Name": "P-Scope", "Rotation": [1, 0, 0, 0], "Translation": [0, 2.5, 4], "Scale": 1}' \
  -o Receiver-new.nif
esx nif remove Receiver-new.nif 'blocks/3/BSConnectPoint::Parents/Connect Points' 1 -o Receiver-old.nif

Without --index, the new entry goes to the end. Indexes start at 0.

Furniture markers

esx nif furniture-markers Bench.nif
esx nif furniture-markers Bench.nif --copy-from Template.nif -o Bench-new.nif

The command lists the markers of a node, or copies them from a template mesh. It does not change the marker flags of the FURN record. nif insert and nif remove also work on a marker array.

Remove unused blocks

A mesh tool can leave blocks in a file that no other block uses. “Remove” in NifSkope takes a branch out of its parent node, and the blocks of the branch stay in the file. nif prune removes each block that the root of the mesh does not reach:

esx nif prune Edited.nif --dry-run
esx nif prune Edited.nif -o Pruned.nif

A block is in use when a chain of links goes from a root to it. A link is a reference that owns its target: a child, a shader, a texture set, extra data, a controller. A pointer does not keep a block. Examples of pointers are the target of a collision object and a bone of a skin.

The report lists each removed block in removed, with its index and its type:

{"changed":true,"removed":[{"index":5,"type":"BSTriShape"},{"index":6,"type":"BSEffectShaderProperty"},{"index":7,"type":"NiAlphaProperty"}],
 "blocks":{"before":17,"after":14},"references":{"count":38,"changed":9},"string_indices":15,
 "bytes":{"before":24148,"after":18894},"written":true}

Each later block gets a smaller index, so references.changed counts the reference fields that esx wrote again. A pointer to a removed block becomes -1. Each other byte of each block stays, and the string table keeps each entry. Block indexes in field paths change, so run nif show again before the next nif set.

--dry-run writes nothing and needs no -o. A mesh with no unused block gives "changed": false and an output with equal bytes.

esx knows the references of the 114 block types of the vanilla Fallout 4 meshes. A mesh with another block type stops the command with the reason NIF_BLOCK_UNMAPPED, because that block can have a reference that esx cannot change.

Materials

esx material show Gun.bgsm
esx material create bgsm -o Gun.bgsm
esx material set Gun.bgsm textures/diffuse 'MyGun/Receiver_d.dds' -o Gun.bgsm --overwrite
esx material set Gun.bgsm two_sided true -o Gun.bgsm --overwrite --dry-run
esx material import bgsm Gun.json -o Gun.bgsm

material show lists each field with its type. material create makes a material with default values, so set its textures before you use it. material set changes one field and keeps the other bytes. A path field takes text, and the other fields take JSON. material import converts the JSON that the Creation Kit and xEdit tools write. The report lists the keys that it did not use.

esx supports material versions 0, 1 and 2. It does not show the result, so check each change in the game.

Find what a file needs

esx resource dependencies 'meshes/weapons/mygun/receiver.nif' --recursive --fail-on-missing

The command reads the textures and materials that a mesh names, and the textures that each material names. It finds each file in the loose folders and the archives, and it lists the files that are missing.

See the parts of a weapon

Two weapons of one mod can use the same mesh for a part. Then they look the same in the game. plugin weapon-parts shows this before a game test. It reads the plugin and the files, and it starts no game.

esx plugin weapon-parts MyGuns.esp MyRifle MyCarbine
MyRifle [WEAP:00000808] My rifle (MyGuns.esp)
  combination 0 (no name), the first with the field Default. Combinations in the object template: 1
  ATTACH POINT     PART                        NAME            FOUND IN  MESH
  (weapon model)   -                           -               loose     meshes/weapons/mygun/dummy.nif
  ap_gun_receiver  MyRifleReceiver [00000803]  Rifle receiver  loose     meshes/weapons/mygun/receiver.nif
  ap_gun_barrel    MyRifleBarrel [00000804]    Long barrel     loose     meshes/weapons/mygun/barrellong.nif
  ap_gun_scope     MyRifleSights [00000805]    Iron sights     -         (no mesh)

MyCarbine [WEAP:00000809] My carbine (MyGuns.esp)
  combination 0 (no name), the first with the field Default. Combinations in the object template: 1
  ATTACH POINT     PART                          NAME              FOUND IN  MESH
  (weapon model)   -                             -                 loose     meshes/weapons/mygun/dummy.nif
  ap_gun_receiver  MyCarbineReceiver [00000806]  Carbine receiver  loose     meshes/weapons/mygun/receiver.nif
  ap_gun_barrel    MyCarbineBarrel [00000807]    Short barrel      MISSING   meshes/weapons/mygun/barrelshort.nif

Meshes that more than one weapon uses: 2
  meshes/weapons/mygun/dummy.nif
      MyRifle: model
      MyCarbine: model
  meshes/weapons/mygun/receiver.nif
      MyRifle: ap_gun_receiver (MyRifleReceiver)
      MyCarbine: ap_gun_receiver (MyCarbineReceiver)
Different paths with the same content: 0
Meshes of each weapon
  MyRifle: 2 shared, 1 own
  MyCarbine: 2 shared, 1 own

In this example the two weapons have the same receiver mesh, and the barrel mesh of the carbine has no file.

A weapon is an editor ID or a FormID. Each row is one object mod (OMOD) from the Includes list of the default combination of the object template. The default combination is the first that has the field Default. If no combination has it, the report uses the first combination. --combination selects a different one by its name or by its index from 0. The column FOUND IN says where the mesh is: loose, the name of the archive, or MISSING. The lookup uses --data, --archive and the archives of the plugin, as plugin assets does.

With two or more weapons, the report lists each mesh that more than one weapon uses, with the attach point and the part of each weapon. It also lists different paths whose files have the same SHA-256. Paths are equal without case, and / is equal to \.

Code Type Meaning
WEAPON_NO_OBJECT_TEMPLATE Warning The weapon has no object template, so the report has no parts for it.
WEAPON_PART_NOT_FOUND Warning The object template includes an OMOD that no loaded plugin has.
WEAPON_PART_MESH_MISSING Warning The mesh of a part has no file, or esx cannot read it.
WEAPON_MESH_MISSING Warning The model or the first-person model of the weapon has no file, or esx cannot read it.
NOT_FOUND Error, exit 3 No loaded plugin has the weapon.
INVALID_ARGUMENT Error, exit 4 The record is not a WEAP (details.reason is NOT_A_WEAPON), or --combination names no combination.

A missing mesh is a warning, and the exit code stays 0. With --fail-on-missing the exit code is 7. An object mod with the record flag Mod Collection is one row, and its members follow it with the origin collection EDITORID. The members are alternatives, and the game uses one of them.

Make a mesh from a model

nif import makes a mesh from a model file with no other tool. The model is a glTF 2.0 file: a .glb file, or a .gltf file with its .bin file. Blender writes this format with no add-on. This section is about a new mesh. A job file can also name a mesh that the command fills with the geometry of the model: see Fill a template.

esx nif import AxisBlock.glb -o AxisBlock.nif
esx nif import AxisBlock.glb -o AxisBlock.nif --material AxisBlock=Materials/Weapons/10mmPistol/10mmCompensator.bgsm --overwrite
esx --data '/path/to/Fallout 4/Data' nif import AxisBlock.glb --job AxisBlock.mesh.toml -o AxisBlock.nif --overwrite

With no template, the output is a complete mesh: a NiNode root, the node tree, one BSTriShape for each primitive (a BSSubIndexTriShape for a primitive with a segment table or a skin) with a BSLightingShaderProperty and a BSShaderTextureSet, the alpha properties and the connect point blocks. The blocks are in the order of the vanilla weapon meshes. A model with a skin also gives the bone nodes and the skin blocks: see Skinned meshes.

The report of the first command, for the test model of esx (a block with two shapes):

{"model":"AxisBlock.glb","output":"AxisBlock.nif","job":null,"scale":69.99124908447266,"nodes":2,
 "shapes":[{"name":"Body:0","source":{"node":"Body:0","primitive":0},"vertices":72,"triangles":36,
   "precision":"half","position_error":0.0012727327411994338,"tangents":"calculated",
   "material":"Materials\\Weapons\\EsxAxisBlock\\AxisBlock.bgsm","textures_from_material":false,"alpha":"none","segments":null},
  {"name":"Slide:0","source":{"node":"Slide:0","primitive":0},"vertices":24,"triangles":12,
   "precision":"half","position_error":0.00048756046453490853,"tangents":"calculated",
   "material":"Materials\\Weapons\\EsxAxisBlock\\AxisBlockSlide.bgsm","textures_from_material":false,"alpha":"none","segments":null}],
 "connect_points":{"parents":["P-Sight"],"children":["C-Muzzle"]},
 "ignored":[],"warnings":[],"template":null,"collision":null,"blocks":10,"bytes":3612,"written":true}
Field Meaning
scale The count of game units for one unit of the model.
position_error The largest distance in game units between a vertex of the model and the stored vertex.
tangents model when the primitive has tangents, or calculated.
textures_from_material True when esx read the material file and filled the texture set.
alpha none, test or blend.
segments null for a BSTriShape. For a BSSubIndexTriShape: the count of segments, the total with the subsegments, the ssf path and the source of the table (model, template or default). See Segments.
skins One entry for each shape with a skin. See Skinned meshes. The list is empty for a rigid model.
ignored What the model has and the mesh cannot hold: cameras, lights, animations, morph targets, textures, images.
template null for a new mesh. With a template: the file and the counts of blocks. See Fill a template.
collision null, or the mesh that gave the collision. See Copy the collision of a mesh.

--dry-run writes nothing and needs no -o.

What the model becomes

In the model In the mesh
The point (x, y, z) The point (x, -z, y). Y of the model is up, and Z of the game is up.
One unit scale game units. The default is 69.99125: one unit is 1 meter. --scale 1 is for a model in game units.
A node with no mesh A NiNode with the same name, translation, rotation and scale.
A node with a mesh of one primitive and with no child A shape with the name and the transform of the node.
Each other node with a mesh A NiNode, and one shape below it for each primitive, with the names NAME:0, NAME:1.
A node with no mesh and no child whose name starts with P- A parent connect point with the transform of the node. Its parent is the node above it, or the root.
One root node The root of the mesh. A scene with more roots gets a new root with the name of the output file.
TEXCOORD_0 The UV of the vertex. A primitive with no UV is the error MODEL_NO_UV.
NORMAL The normal. With none, esx calculates the normals and gives the warning MODEL_NO_NORMALS.
TANGENT The tangents. With none, or with tangents = "calculate", esx calculates them.
COLOR_0 The vertex colors. Only a primitive with colors gets the color flag.
JOINTS_0 and WEIGHTS_0, on a node with a skin The 4 bone indices and the 4 weights of each vertex. See Skinned meshes.
A joint of a skin that a vertex uses A NiNode below the root with the name of the joint: a bone node. A joint that no vertex uses is not a node of the mesh.
The name of a material The key for the material path. See below.
alphaMode MASK or BLEND An alpha property with an alpha test or with a blend.

A node with three different scale values is the error MODEL_SCALE_NOT_UNIFORM. A primitive with more than 65,535 vertices is the error MESH_VERTEX_LIMIT. Divide the object in the modelling program.

The job file

A model file cannot hold each value of a mesh, and Blender does not keep each value that it can hold. The job file has these values. It has the name of the model with .mesh.toml: AxisBlock.mesh.toml for AxisBlock.glb. With no --job, the command reads this file beside the model when it exists. Each key is optional.

scale = 69.99125
tangents = "auto"

[materials]
AxisBlock = 'Materials\Weapons\10mmPistol\10mmCompensator.BGSM'
AxisBlockSlide = 'Materials\Weapons\10mmPistol\10mmCompensator.BGSM'

[shape."Slide:0"]
precision = "half"
alpha = "none"

[connect]
children = ["C-Muzzle"]

[[connect.parent]]
name = "P-Sight"
parent = ""
translation = [0.0, 4.2, 4.9]
rotation = [0.9659258, 0.258819, 0.0, 0.0]
scale = 1.0
Key Rule Default
scale Game units for one model unit. --scale replaces it. The value that nif export wrote into the model, else 69.99125
tangents "auto" uses the tangents of the model when it has them. "calculate" always calculates. "auto"
bsx_flags The number of the BSXFlags block on the root. The value of the mesh of [collision], else the value of the template, else no block. 149 of the 204 vanilla weapon meshes with no collision have none.
behavior_graph The project file of the behavior graph of the mesh, as a path from Meshes: "Effects/EffectBehaviors/MyGunFXHKB/MyGunFX.hkx". The command writes it into the BSBehaviorGraphExtraData block of the root and makes the block when the mesh has none. The game runs that graph for the model. See The graph of the weapon model. The value of the template, else no block
[materials] A material path for the name of a material of the model. --material NAME=PATH adds or replaces an entry. See below
[shape.NAME] Values for one shape of the output.
precision "half" stores positions as 16 bit floats, as each vanilla weapon shape. "full" stores 32 bit floats. "half"
alpha "none", "test" or "blend". From the material file, else from alphaMode of the model
[connect] children The names of the child connect points. The names that nif export wrote into the model, else none
[[connect.parent]] One parent connect point. translation is in game units, and rotation is W, X, Y, Z. An entry replaces a P- node of the model with the same name. The P- nodes of the model
template, template_file The mesh that the command fills. See Fill a template. No template
template_shape (in [shape.NAME]) The name of the template shape that this shape replaces. The template shape with the same name
unmatched What occurs with a template shape that no shape of the model replaces: "error", "keep" or "remove". "error"
[collision] from, from_file The mesh that gives its collision to the root of the output. See Copy the collision of a mesh. The collision of the template, else none
segments (in [shape.NAME]) The segment table of the shape: "model", "template", "default" or "none". See Segments. "model" for a model with a table, else "template" for a shape that replaces a template shape, else "default" for a new shape with a skin
skeleton, skeleton_file The skeleton mesh of the actor. A bone node that the template does not have takes its transform from the node of this mesh with the same name. skeleton is a Data path, and skeleton_file is a file path from the folder of the job file. See Skinned meshes. The nodes of the template, else the joints of the model

A key that esx does not know, a wrong value, a material name that the model does not have and a shape name that the output does not have are the error MESH_JOB_INVALID.

Materials and textures

The material path of a shape is the first of these: the entry of [materials] for the name of its glTF material, extras.esx.material of the glTF material, the material name when it ends with .bgsm. With none, the shader has no material and the warning is MESH_NO_MATERIAL. The mesh gets the path with backslashes, also when the job file has /: the game finds no material by a path with /, and then shows the shape in one purple color.

With the global option --data, the command reads each material file from the Data folder and from the archives of the game. It copies the texture paths into the texture set, and it gives the shape an alpha test when the material has one. A path that names no file gives the warning MESH_MATERIAL_NOT_FOUND. With no --data, the texture set is empty.

The new shader has the most frequent values of the vanilla weapon shaders. Change a field that nif show lists with nif set.

Precision

Half precision has a step of 1/16 game unit for a coordinate between 64 and 128 units from the origin of the shape, and of 1/8 unit between 128 and 256 units. When it moves a vertex by more than 1/32 unit, the warning is MESH_HALF_PRECISION. Then set precision = "full" for the shape. A coordinate above the range of half precision, 65,504 units, is the error MODEL_INVALID.

What a game test showed

A game test put the test model on a copy of the 10mm pistol as a muzzle part, with the vanilla material 10mmCompensator.BGSM. Fallout 4 1.11.240 loaded each mesh and showed it at the muzzle with the correct axes.

  • A mesh with an empty texture set and a mesh with a full texture set gave the same picture. The game takes the textures from the material file.
  • A shape with no material path showed the textures of its texture set.
  • A weapon part with precision = "full" gave the same picture as the part with half precision.
  • A shape with a material that has an alpha test gave the same picture with and without the alpha property in the mesh. The game takes the alpha test from the material file.
  • Vertex colors showed on a shape with no material path. They did not show on a shape with the material 10mmCompensator.BGSM. A later game test found the cause: that material has grayscale_to_palette_color. Vertex colors change the color of the texture only with a material that does not have this setting.

What the command does not make

Not made Other way
Collision [collision] from copies it from a mesh that has it. A template keeps its own.
Eye data and the morph files of a head part None in this version.
An effect shader (a .bgem material), for glass and glow A template keeps the effect shader of a shape.
A controller and a particle system A template keeps them.

The command writes a new file. It does not change the template or the model.

Fill a template

A template is a mesh that nif import fills with the geometry of a model. The output keeps each block of the template that the command does not replace, with each byte: the nodes with their transforms, the shaders, the texture sets, the alpha properties, the collision, the controllers and the extra data. Use a vanilla mesh as the template when the new part must have something that esx cannot make.

The output needs Why a template Other way
Collision (bhkNPCollisionObject, bhkPhysicsSystem) The physics system is a compiled Havok byte array. 739 of the 943 vanilla weapon meshes have one. [collision] from copies it, with no template
A controller with its interpolators, or a particle system esx does not make these blocks. 51 vanilla weapon meshes have a NiTransformController. None
An effect shader (BSEffectShaderProperty) The command makes a lighting shader only. 443 of the 2,761 vanilla weapon shapes use an effect shader. None
BSBehaviorGraphExtraData and other extra data The command makes BSXFlags and the connect point blocks only. nif connect-points --copy-from for points
A lighting shader with other values than the defaults A new shader has the most frequent vanilla values. nif set on the output
Nodes that the animations of the weapon move A template node keeps its name, its place in the tree and its transform. Nodes with the same names in the model

A rigid shape with a .bgsm material and no collision needs no template.

esx --data '/path/to/Fallout 4/Data' resource extract Meshes/Weapons/10mmPistol/10mmCompensator.nif -o Meshes/Weapons/10mmPistol/10mmCompensator.nif
esx nif export Meshes/Weapons/10mmPistol/10mmCompensator.nif -o Compensator.glb --job
# Change Compensator.glb in the modelling program. Then:
esx --data '/path/to/Fallout 4/Data' nif import Compensator.glb -o Compensator.nif

nif export --job writes the source mesh into the job file, so the last command fills the source mesh. Three places name a template:

Place Meaning
template = "Meshes/Weapons/10mmPistol/10mmCompensator.nif" A Data path. The command finds it in the Data folder and the archives of --data. When it is not there, the command reads the path below the folder of the job file.
template_file = "src/Compensator.nif" A file path from the folder of the job file.
--template FILE A file path from the working folder. It replaces the two keys.

The two keys together are the error MESH_JOB_INVALID. A template that is not a file is the error MESH_TEMPLATE_NOT_FOUND, with exit code 3.

What the command does with each part

Part Rule
Root The root of the model is the root of the template. The two names can be different.
Nodes A node of the model is the template node with the same name. The template node keeps its transform and its parent. A node that the template does not have is a new NiNode below the node of its parent, at the end of the file.
Shapes A shape of the model replaces the template shape with the same name, or with the name of template_shape. With two shapes of one name, the first replaces the first.
A replaced shape The block keeps its index, its name, its flags, its transform, its vertex flags, its shader, its alpha property and each bit of its vertex descriptor. The command writes the vertices, the triangles, the two counts and the bounds.
Positions The world position of a vertex in the output is its world position in the model. When the template shape or a node above it has another transform than in the model, the command moves each vertex into the space of the template shape, and turns each normal and tangent.
A new shape A shape that the template does not have is a new BSTriShape (a BSSubIndexTriShape for a shape with a segment table or a skin) with a new lighting shader, below the node of its parent, at the end of the file. The report has the note MESH_SHAPE_ADDED in template.notes.
A template shape with no shape of the model It follows unmatched. "error" stops with MESH_TEMPLATE_SHAPE_UNMATCHED and writes no file. "keep" keeps the shape and gives the warning with the same code. "remove" deletes the shape with its shader, its texture set and its alpha property, when no other block uses them.
Material A replaced shape keeps the shader block of the template. When the model gives another material path, the path goes into that block: a .bgsm path for a lighting shader, a .bgem path for an effect shader. The other kind is the error MESH_JOB_INVALID. With --data, the texture paths of a new .bgsm file go into the texture set.
precision and alpha of [shape.NAME] A replaced shape has the precision of the template shape, and precision changes it. The key alpha on a replaced shape is the error MESH_JOB_INVALID: the shape keeps the alpha property of the template.
Vertex colors A replaced shape has colors only when the template shape has them. A model with no colors then gives white. A model with colors for a template shape with none gives the warning MODEL_ATTRIBUTE_IGNORED.
BSXFlags The block of the template stays. bsx_flags changes its value.
BSBehaviorGraphExtraData The block of the template stays. behavior_graph changes its path, and makes the block for a template with none.

A template shape with a data size of 0 has no geometry in the mesh. It stays, and no shape replaces it. A template shape with eye data, or with another type than BSTriShape and BSSubIndexTriShape, cannot get new geometry in this version: the error is MESH_JOB_INVALID. Take such a shape out of the model and set unmatched = "keep". A template shape with a skin gets new geometry and new weights: see Skinned meshes.

The job file of the test model in the template of the vanilla 10mm compensator. The shape Body:0 replaces the shape of the template. The node WeaponBolt and the shape Slide:0 are new:

template = "Meshes/Weapons/10mmPistol/10mmCompensator.nif"

[materials]
AxisBlock = 'Materials\Weapons\10mmPistol\10mmCompensator.BGSM'
AxisBlockSlide = 'Materials\Weapons\10mmPistol\10mmCompensator.BGSM'

[shape."Body:0"]
template_shape = "Mod10mmCompensator:0"

The template of its report:

{"file":"Meshes/Weapons/10mmPistol/10mmCompensator.nif","kept":7,"replaced":2,"added":4,"removed":0,
 "shapes":{"replaced":["Mod10mmCompensator:0"],"unchanged":[],"added":["Slide:0"],"kept":[],"removed":[]},
 "nodes_added":["WeaponBolt"],
 "notes":[{"code":"MESH_SHAPE_ADDED","message":"the shape `Slide:0` of the model is not in the template; it is a new shape below the node `WeaponBolt`, with a new shader"}]}
Field Meaning
kept The count of blocks of the template with equal bytes in the output.
replaced The count of blocks of the template with other bytes. Here: the shape, and the root, which has one more child.
added The count of blocks that the template does not have.
removed The count of blocks of the template that the output does not have.
shapes The names of the template shapes with new geometry (replaced), with the same geometry (unchanged), with no shape of the model (kept, removed), and the names of the new shapes (added).

A shape that did not change

A shape of the model with the geometry of the template shape keeps its block, with each byte. So a model that comes back with one changed object changes one shape block, and each other shape keeps the tangents of the vanilla mesh.

The geometry is the same when each position, UV, vertex color and triangle is equal, and each normal value is within 1 of 255. Blender makes each normal a unit vector, which moves a value by 1. When the model has tangents, each value of them must also be within 1 of 255.

A shape with a skin has one more rule: for each vertex, the weight of each bone is within 0.002 of the weight in the template. The order of the four weights of a vertex is not part of the rule. One step of a stored weight is 0.0005, and Blender makes the sum of the weights 1 again, which moved a weight by 0.0005 at most in the tests.

With tangents = "calculate", the command calculates the tangents of each shape, and no shape block keeps its bytes.

A cycle with nif export --job and nif import on the 919 vanilla weapon meshes that have a shape with geometry: 919 outputs are equal to the source in each byte. 7 of these meshes have a shape with a skin.

The vanilla mesh 10MMPistol.nif went through Blender 4.5.13 with no edit and with the default export options. 54 of its 55 blocks came back with equal bytes: each node, each connect point, and 5 of the 6 shapes. Blender wrote the sixth shape with 244 vertices in place of 242, so that shape got new vertex data. After a move of the vertices of one more shape in Blender, that shape was the only other block with new bytes.

Connect points

The parent connect points of the model replace the entries of the BSConnectPoint::Parents block of the template. The names of the child points replace the names of the template. A model with no P- node and a job file with no [[connect.parent]] keep the block of the template, and the same rule applies to the child names.

A value of a point changes in the last bits when it goes through a model file: the model has the rotation as a quaternion of a node. So an entry of the template stays, with each byte, when the model has a point with the same name on the same node and each value is equal within 1 part in 1,000,000. For a value below 1, the limit is 0.000001. A quaternion and its negative are the same rotation.

The entries keep the order of the template, and a point that the template does not have goes to the end. A point of the template that the model does not have goes out.

A point of the model keeps its world position, as a vertex does. An entry of [[connect.parent]] has its values with no change.

A template node whose name starts with P- comes back from a model as a node with no child. It stays the node when the template has no connect point with its name.

Copy the collision of a mesh

[collision]
from = "Meshes/Weapons/10mmPistol/10MMPistol.nif"

from is a Data path, and from_file is a file path from the folder of the job file. The command copies a collision object of that mesh, with the physics system that it uses, to the root of the output. The blocks go to the end of the file. The BSXFlags value of the output becomes the value of that mesh, unless the job file has bsx_flags. The key works with and without a template. A collision object that the root of a template has goes out first.

The command takes the collision object of the root of the source. 102 of the 739 vanilla weapon meshes with collision have none on the root: then it takes the first collision object of the file, and the field node of the report names the node that had it. The physics data is in the space of that node. The command does not change it, so select a source whose form and size are near the form of the new mesh.

The collision of the report:

{"file":"Meshes/Weapons/10mmPistol/10MMPistol.nif","node":"Pistol10mmReceiver","blocks":2,"bsx_flags":203}

A source that is not a file is the error MESH_TEMPLATE_NOT_FOUND. A source with no collision object is the error MESH_JOB_INVALID. esx does not make new collision from geometry.

What a game test showed for a template and for collision

A game test in Fallout 4 1.11.240 used the test model on copies of the 10mm pistol.

  • The test model in the template of the vanilla compensator mesh, as a muzzle part: the game showed the replaced shape at the muzzle with the correct axes. It also showed the new shape below the new node. So the game accepts new blocks at the end of a template file.
  • A weapon that the player drops falls to the floor only when the model of the weapon record has a collision object. The collision of a part mesh alone does not count: a weapon whose only collision was in the mesh of a part stayed in the air where the player dropped it. This was the same for a part with copied collision and for the vanilla receiver mesh with its own collision.
  • With [collision] from on the model of the weapon record, the dropped weapon fell and stayed on the floor. A new parent object with the copied collision of 10mmRecieverDummy.nif gave the same result as the vanilla file. A model with the collision of 10MMPistol.nif, which has its collision object on a child node, also fell and stayed on the floor.
  • A model in the template of 10mmRecieverDummy.nif kept the collision of the template and fell to the floor.
  • The form of the collision is the form of the source. The collision of the vanilla parent object is small: with it, a part 14 units long stood on its end with one half below the floor.

So put the collision on the mesh that the model key of the weapon names. For a weapon with parts, that is the parent object.

Skinned meshes

An armor or a piece of clothing has a skin: each vertex has up to 4 bones and 4 weights, and the game moves the vertex with the bones of the actor. nif export writes the skin into the model, and nif import reads it.

In the mesh In the model
A bone of a shape: a NiNode that the BSSkin::Instance of the shape names A joint of the skin of the shape node, in the order of the bone list.
The skin to bone transform of a bone, in BSSkin::BoneData The inverse bind matrix of the joint, through the axes rule and the scale rule.
The 4 bone indices and the 4 weights of a vertex JOINTS_0 and WEIGHTS_0. The export writes the stored values with no change.
The position of a vertex The position in the space of the skin. The transform of the shape node does not move a skinned vertex.

The game calculates the place of a vertex as bone of the actor * skin to bone * position, with the weights. So the skin to bone transforms must fit the skeleton of the game. The best source for them is a vanilla mesh: export it, and make the new mesh on its joints.

Export a skinned mesh

mkdir -p Meshes/Armor/CombatArmor work
esx resource extract 'Meshes/Armor/CombatArmor/F_Arm_Heavy_L.nif' -o Meshes/Armor/CombatArmor/F_Arm_Heavy_L.nif
esx nif export Meshes/Armor/CombatArmor/F_Arm_Heavy_L.nif -o work/Arm.glb --job

The report of the second command has the skin:

{"nodes": 18, "vertices": 1583, "triangles": 1886,
 "shapes": [{"block": 16, "name": "F_Arm_Heavy_L:0", "vertices": 1583, "triangles": 1886, "material": "CombatArmor_Arm",
   "segments": {"segments": 5, "total": 9, "ssf": "meshes\\Armor\\CombatArmor\\F_Arm_Heavy_L.ssf", "copies": 0}}],
 "skins": [{"shape": "F_Arm_Heavy_L:0", "bones": ["LArm_Collarbone_skin", "LArm_ForeArm1", "LArm_ForeArm1_skin",
   "LArm_ForeArm2_skin", "LArm_ForeArm3_skin", "LArm_Hand", "LArm_ShoulderFat_skin", "LArm_UpperArm_skin",
   "LArm_UpperFat_skin", "LArm_UpperTwist1_skin", "LArm_UpperTwist2_skin", "LArm_UpperTwist2"]}],
 "warnings": []}

The shape is a BSSubIndexTriShape: it has a segment table. The model has the table: see Segments.

The vertices of a vanilla armor mesh are not at the place of the bone nodes. In 2,091 of the 2,338 skins of the vanilla armor, clothes and character meshes, the transform of the bone node times the skin to bone transform is one translation for each bone of the shape. For 1,930 of them it is (0, -0.88, 120.84) game units: the Z value of a stored vertex is 120.84 units below its place at the bones. The matrices of the model have this offset, so a viewer that applies the skin shows the mesh at its bones.

Fill a template that has a skin

esx --data '/path/to/Fallout 4/Data' nif import work/Arm.glb -o out/F_Arm_Heavy_L.nif

The job file that nif export --job wrote names the source mesh as template. With no edit of the model, the output is equal to the source in each byte: template.shapes.unchanged has the shape.

Part Rule
A joint of the model It is the node of the template with the same name. The template keeps the transform of each of its nodes.
A bone of the template shape It keeps its place in the bone list, its node and its skin to bone transform. The matrix of the model for it is not written.
A joint that is a node of the template and not a bone of the template shape A new bone at the end of the bone list of the shape. Its skin to bone transform is the matrix of the model.
A joint that is not a node of the template A new NiNode below the root with the transform of the node of the skeleton mesh with the same name, and a new bone. With no such node, the error is MESH_BONE_NOT_FOUND.
The weights of a vertex The 4 largest, in falling order. Their sum becomes 1 when it differs from 1 by more than 0.002. A vertex with more than 4 weights gives the warning MESH_WEIGHTS_LIMIT.
A vertex with no weight The error MESH_JOB_INVALID, with the count. A vertex of the template with no weight can stay: 4 vertices of 3 vanilla armor meshes are of this kind.
A shape with more than 256 bones The error MESH_BONE_LIMIT. The bone index of a vertex is one byte. The largest vanilla count is 141.
The sphere of each bone When a position or a weight changes, each bone with a vertex gets a new sphere. A bone with no vertex of the new shape keeps its sphere.
The bounds of the shape They stay. Each of the 16,343 vanilla skinned shapes has bounds of 0.
A template shape with a skin and a model shape with none, or the reverse The error MESH_JOB_INVALID.
A vertex with the weights of the template vertex with the same index, within 0.002 It gets the stored weights of the template, with each bit.

A template shape keeps its type. A BSSubIndexTriShape gets the segment table of the model, the table of the template or the default table: see Segments.

A model can have its skin in another space than the template. Blender moves each vertex into the bind pose and writes new matrices. For each bone, inverse(skin to bone of the template) * (matrix of the model) is the transform between the two spaces. The command sends each vertex through the transforms of its bones, with its weights, so the vertex is in the space of the skin of the template again. A position within 0.00025 game units of the template vertex with the same index gets the stored position of the template. position_error of the shape in the report is then the largest distance between such a vertex and its stored position.

Segments

Most shapes of an armor, of clothes and of a body are a BSSubIndexTriShape: a shape with a segment table. The table divides the triangle list into segments, and a segment can have subsegments. Each is one range of triangles. In the vanilla meshes, 15,297 of the 15,518 skinned shapes with geometry below Meshes/Actors, Meshes/Armor and Meshes/Clothes have a table.

The parts of a table are its segments and its subsegments in table order: a segment, then its subsegments, then the next segment. The number of a part is its place in that order, from 0.

In the mesh In the model
The segment or the subsegment of a triangle The vertex attribute _ESX_SEGMENT of its three vertices: the number of the part. The value -1 is for a triangle of no segment.
A vertex that the triangles of two parts use Two vertices at one place, one for each part, so the three vertices of a triangle have one value. The second vertex is at the end of the vertex lists.
The subsegments of each segment, the two numbers and the cut offsets of each subsegment, and the SSF path extras.esx.segments of the mesh.

extras.esx.segments of the arm mesh of the example above:

{"ssf": "meshes\\Armor\\CombatArmor\\F_Arm_Heavy_L.ssf", "copies": 0,
 "segments": [{"subsegments": []}, {"subsegments": []}, {"subsegments": []}, {"subsegments": []},
   {"subsegments": [{"user": 1, "bone": "LArm_UpperArm", "cuts": []}, {"user": 2, "bone": "LArm_UpperArm", "cuts": []},
                    {"user": 3, "bone": "LArm_UpperArm", "cuts": []}, {"user": 60, "bone": "LArm_ForeArm1", "cuts": []}]}]}

This table has 5 segments and 9 parts. The segments 0 to 3 are the parts 0 to 3 and have no triangle. The segment 4 is the part 4, and its subsegments are the parts 5 to 8.

Key Content
ssf The path of the SSF file of the shape. A table with no subsegment has no path.
copies The count of vertices that the export wrote a second time for a second part. An import of a model with no edit makes one vertex of the two again.
segments One entry for each segment, with its subsegments.
user User Index of the subsegment.
bone The name of a bone. The mesh has a number for it, Bone ID: the CRC-32 of the name in lower case, with the start value 0 and no last inversion. The export writes the name when a node of the mesh or one of 15 bones of the human skeleton has that number, and else the number as a text, for example "0x9BF71FF4". With no bone, the number is FFFFFFFF.
cuts The cut offsets of the subsegment: a list of numbers.

27,749 of the 27,777 subsegments of the vanilla meshes with a Bone ID have the number of the name of a node of a vanilla mesh. An SSF file is a JSON file beside the mesh. It names subsegments with the key segment * 65536 + subsegment * 256 and a bone name: 1,437 of the 1,493 subsegments with cut offsets of the vanilla armor, clothes and character meshes have such a key with the name of their bone. esx does not read and does not write an SSF file. No test of esx shows what the game does with user, bone and cuts: keep the values of the vanilla mesh.

The key segments of [shape.NAME] in the job file selects the table of a shape:

Value The table of the shape
"model" The table of the model. The import sorts the triangles by their part and writes the range of each segment and subsegment. The model can have new triangles, less triangles and another triangle order.
"template" The table of the template shape. It keeps each byte when the model has the triangles of the template in the same order. When the model has less triangles, each triangle keeps its part and the table gets new ranges. With other triangles, the shape gets the default table and the warning MESH_SEGMENTS_LOST.
"default" 4 segments with no subsegment and no SSF path, and each triangle in the last segment. 274 vanilla shapes have this table, for example Armor/CombatArmor/M_Torso_Lite.nif.
"none" No table: the shape is a BSTriShape. Only for a shape that the template does not have. 804 of the 825 vanilla skinned shapes in other folders than Actors, Armor and Clothes are a BSTriShape, for example a skinned part of a weapon.

With no key, the table is "model" when the primitive has _ESX_SEGMENT and its mesh has extras.esx.segments. If not, it is "template" for a shape that replaces a template shape, and "default" for a new shape with a skin. A new shape with no skin has no table.

A template shape keeps its type. "none" for a BSSubIndexTriShape of the template and "model" or "default" for a BSTriShape of the template are the error MESH_JOB_INVALID: give the shape of the model another name, so that it is a new shape.

The rules of "model":

  • A triangle is in the part of its three vertices. When they do not have one value, the error is MESH_SEGMENT_MIXED, with the count of such triangles. A vertex at the border of two parts must be two vertices at one place.
  • A value is a whole number from -1 to the last part. Each other value is the error MODEL_INVALID, with the number of the vertex.
  • The triangles of a segment that are in none of its subsegments are first in the segment. 47 vanilla segments have such triangles.
  • A segment with no triangle has the start 0, as in each vanilla table.

The report of nif import has the table of each shape in segments:

{"segments": 5, "total": 9, "ssf": "meshes\\Armor\\CombatArmor\\F_Arm_Heavy_L.ssf", "source": "model"}

The table that esx makes was compared with the vanilla meshes. For each of the 15,548 vanilla shapes with a table, esx read the part of each triangle and made the table again: 15,548 blocks are equal to the source in each byte. 11 of them have triangles of no segment. nifly, a second reader with other code, read the same segments, the same subsegments and the same part of each triangle from 63 shapes that esx wrote and from their sources.

A game test showed three copies of the vanilla suit Clothes/Mayor/SuitM.nif on the player, each with a table that esx made: the table of a model that went through Blender (5,251 of 5,311 triangles, in the reverse order), the table of a model with 2,120 more triangles from an edit in Blender, and the default table. The pictures show the same suit as the vanilla mesh from four sides. The test has no check of an actor that loses a limb.

Make a new skinned mesh

With no template, the command makes each block of the skin:

Block or value What the command writes Vanilla count
The shape A BSSubIndexTriShape with the default segment table, or a BSTriShape with segments = "none". It has the skinned vertex flag, 32 bytes for each vertex, 36 with vertex colors. The vertex descriptor that esx calculates is the stored one in 2,338 of 2,338 skinned shapes of the armor, clothes and character meshes. 11,571 skinned shapes of other actors have one more bit, which a template keeps.
The bounds of the shape 0. 16,343 of 16,343 skinned shapes.
Shader flags 1 The value of a rigid shape, with the bit 0x2. 14,133 of 14,133 lighting shaders of a skinned shape.
BSSkin::Instance and BSSkin::BoneData Directly after the shape. The skeleton root is the root node. The two blocks follow the shape in 14,962 of 16,343 shapes. The root is the skeleton root in 2,338 of 2,338 armor skins.
A bone node A NiNode with the flags 14, below the root and before each shape, with the world transform of the joint. 46,768 of 46,794 bone nodes have the flags 14, and 44,218 are below the root.
The skin to bone transform The inverse bind matrix of the joint.
The sphere of a bone The vertices with a weight above 0 for the bone, in the space of the skin: the center is the middle of the box of their least and largest coordinates, and the radius is the largest distance from it. The center then goes into the space of the bone. The stored sphere within 1 percent of the radius for 43,791 of 46,673 bones.

The bones of a shape are the joints that one of its vertices uses with a weight above 0. A joint that no vertex uses is not a bone and not a node of the mesh. A node of the model that is not a joint, and that is below a joint, goes below the bone node of that joint.

The key skeleton names the skeleton mesh of the actor. A bone node then has the transform of the node of that mesh with the same name. For a human it is Meshes/Actors/Character/CharacterAssets/skeleton.nif. A joint with a name that the skeleton mesh does not have keeps the transform of the model. The key changes the bone nodes only: the skin to bone transform is the matrix of the model in each case. In the vanilla armor meshes, 31,935 of 34,666 bone nodes with a name of that skeleton have its transform within 0.01 game units.

The arm band is the test model of esx with a skin. A program of the repository writes it:

cargo run -p esx-model --example arm_band -- ArmBand.glb

It is a tube of 12 segments and 5 rings with a stud, 89 vertices and 108 triangles. Its three joints have the names of three bones of the left forearm, 0.088 meters apart on the X axis of the model. The job file ArmBand.mesh.toml:

skeleton = "Meshes/Actors/Character/CharacterAssets/skeleton.nif"

[materials]
ArmBand = "Materials/Armor/Combat/CombatArmor_Arm.bgsm"
esx --data '/path/to/Fallout 4/Data' nif import ArmBand.glb -o ArmBand.nif

skins of the report:

[{"shape": "ArmBand:0",
  "bones": [{"name": "LArm_ForeArm1_skin", "from": "skeleton"}, {"name": "LArm_ForeArm2_skin", "from": "skeleton"},
            {"name": "LArm_ForeArm3_skin", "from": "skeleton"}],
  "added": [], "weights_limited": 0, "weights_scaled": 0, "weights_none": 0}]
Field Meaning
bones Each bone of the shape, in the order of its bone list. from is the source of the transform of the bone node: template, skeleton or model.
added With a template: the bones that the template shape did not have.
weights_limited The count of vertices of the model with more than 4 weights.
weights_scaled The count of vertices whose weights the command divided by their sum.
weights_none The count of vertices of the model with no weight. It is not 0 only when each such vertex has no weight in the template.

The mesh has 9 blocks: the root, 3 bone nodes, the shape, the skin instance, the bone data, the shader and the texture set. esx nif shapes ArmBand.nif --vertices gives the weights and the bone indices, and esx render mesh ArmBand.nif -o ArmBand.png draws the mesh in its bind pose, with no skin pose.

A game test showed the arm band around the left forearm of the player: see From a model to the game. The game does not use the transform of a bone node in the mesh, so the key skeleton changes no picture. It makes the bone nodes equal to those of a vanilla armor mesh.

Blender and a skin

Blender 4.5.13 read and wrote skinned models of esx with no window and with the default options.

Subject Result
The arm band, with no edit The joint names, the joint order, each inverse bind matrix, each position, each joint index and each weight came back equal. A normal value changed by 1 of 255 at most.
A vanilla armor mesh, F_Arm_Heavy_L.nif, with no edit The import with the source as the template gave the source again, with each byte.
The names and the order of the joints Equal. The root node of the joints is the armature object and keeps its name.
The positions Blender moves each vertex into the bind pose: 1.7266 meters up for the vanilla arm mesh. It writes new inverse bind matrices for that pose. The command moves each vertex back (see above), and a position came back within 0.00004 game units.
The weights Blender makes the sum of the weights of a vertex 1 again. A weight changed by 0.0005 at most.
A file with two skinned shapes Blender writes each bone of the armature as a joint of each skin, so the joint indices change. The command finds a bone by its name.
A vertex with two normals or two UV values Blender can divide it, so the vertex count grows: 1,020 became 1,023 in one mesh. The triangles keep their order, and a segment table stays.
Two triangles with the same three vertices Blender removes one of them: 60 of 5,311 triangles in Clothes/Mayor/SuitM.nif. Each other triangle keeps its part, and the segment table gets new ranges.
A vertex that the export wrote two times, for two parts of a segment table Blender keeps the two vertices. The command makes one vertex of them again when the triangles are the triangles of the template, so the shape can keep its block.
The segment table With the export options “Attributes” and “Custom Properties”, _ESX_SEGMENT and extras.esx.segments come back, and the table is the table of the model. With the default options they do not come back, and the table is the table of the template.

20 vanilla armor and clothes meshes with 31 skinned shapes went through Blender with no edit. The import with the source as the template wrote 20 meshes, and 11 of them are equal to the source in each byte. The bone list of each of the 31 shapes is equal to the source. In the 28 shapes that kept their vertex count, each of the 31,223 vertices has the stored position, bone indices and weights of the source.

20 other vanilla meshes, with 22 shapes that have a segment table, went through Blender two times: with the default options, and with “Attributes” and “Custom Properties”. In each run, 21 tables are equal to the table of the source and 11 meshes are equal to the source in each byte. The other table is of Clothes/Mayor/SuitM.nif: it has the same segments and subsegments, with ranges for the 5,251 triangles that Blender kept.

A program then made new faces in Blender: it divided the edges of 606 faces of one part of that suit. The model had 7,371 triangles in place of 5,251. The import with segments = "model" gave the 2,120 new triangles to that part, and each other part kept its count of triangles.

After an edit in Blender with a program (708 of the 1,583 vertices of the arm mesh moved by 1 centimeter and got the weight 1 for the bone LArm_Hand), the import gave those 708 vertices the new position and the new weight. The 875 other vertices kept each bit of their position and of their weights, and the shape kept its type and its segment table.

Numbers from the vanilla meshes

A cycle with nif export --job and nif import on the 1,982 vanilla armor, clothes and character meshes that have a shape with geometry: 1,979 outputs are equal to the source in each byte, with 2,336 skinned shapes. The 3 other meshes stop: 2 have a shape with eye data, and 1 has a shape with no UV.

The same cycle with tangents = "calculate" writes each shape again. Each of the 2,336 skinned shapes kept its type, its segment table, its bone list and its positions, and each of its 3,068,676 vertices kept the weight of each bone.

2,281 shapes of these meshes have a segment table. The export wrote 71,238 vertices a second time for a second part, and the import made one vertex of each pair again. In the cycle that writes each shape again, each of the 2,279 tables of the meshes that the import wrote is equal to the table of the source. An import of the same models with no template made 2,218 shapes with a table, and each table and each triangle list is equal to the source.

Blender

Blender imports and exports a model file with File, Import or Export, glTF 2.0. esx was tested with Blender 4.5.13.

  • The scene has the game axes. X is to the right, the front of a gun is +Y, and up is +Z. Blender converts to the Y up axes of the file.
  • With the default scale, 1 meter in Blender is 69.99125 game units.
  • Name an object as the shape in the mesh: Barrel:0. The name of the Blender object is the name of the node, and so of the shape.
  • An empty object with a name that starts with P- is a parent connect point. Put it where the next part attaches.
  • A model that goes through Blender with no edit gives the same shape data: each position, UV, normal and triangle of the test model came back equal.
Export option Default Effect
Data, Mesh, Tangents Off Writes the tangents of Blender, and esx uses them. With it off, esx calculates the tangents. For the test model both gave the same bytes.
Data, Mesh, Vertex Color Material Writes vertex colors only when the material uses them. Select “Active” to always write them.
Include, Custom Properties Off Keeps the extras values of a model that nif export wrote: the material paths, the names of the child connect points and the segment table. With it off, give the paths and the names in the job file.
Data, Mesh, Apply Modifiers Off With it off, a modifier is not in the file. A bevel modifier changed the test model from 72 to 288 vertices only with this option.
Data, Mesh, Attributes Off Writes the vertex attribute _ESX_SEGMENT. Set it, with “Custom Properties”, for a shape with a segment table and new faces. See Segments.
Data, Armature, Use Rest Position Armature On Keep it on. The joints are then written in the rest pose, with the matrices of that pose.
Data, Skinning, Bone Influences 4 The count of weights for each vertex. A mesh of the game has 4.

What an edit in Blender does to the import:

Edit Result
A new object name The shape has the new name. Change the [shape.NAME] tables of the job file.
Two objects joined, with two materials One node with the shapes NAME:0 and NAME:1.
A scale on one axis that is not applied The error MODEL_SCALE_NOT_UNIFORM. Use Object, Apply, Scale.
A rotation or a translation that is not applied The node or the shape has that transform. The vertices do not change.
Merge by distance, and smooth shading Fewer vertices: 72 became 60 in the test model. A UV seam keeps its two vertices.
An object with no UV map The error MODEL_NO_UV.
A material with a new name The entry of [materials] for the old name is the error MESH_JOB_INVALID. Give the new name.

Blender gives the second of two materials with one name the suffix .001, and a material name has at most 63 bytes. So a name in [materials] is safer than a path as the name.

A vertex color is not always equal after Blender: 73 of the 256 byte values come back changed by 1.

Models in a project

esx build converts the model files of a project. Put a model into the folder meshes/ with the path of its mesh:

mymod/
  meshes/
    Weapons/EsxAxisBlock/
      AxisBlock.glb             # becomes Meshes/Weapons/EsxAxisBlock/AxisBlock.nif
      AxisBlock.mesh.toml       # optional: the job file of the model
  assets/
    Materials/Weapons/EsxAxisBlock/AxisBlock.bgsm
    Textures/Weapons/EsxAxisBlock/AxisBlock_d.dds

The assets step makes each mesh with the conversion of nif import, before it copies the asset folders into the stage. The same model and the same job file give the same bytes in the build and in the command. The pack step puts the mesh into the Main archive, and the release check reads it as each other mesh. A file of meshes/ that is not a .glb file or a .gltf file is not a model: a .blend file can be beside its export.

esx build examples/fo4-mesh-block --dry-run
esx build examples/fo4-mesh-block

The dry run lists each job in meshes of the assets step:

{"model": "examples/fo4-mesh-block/meshes/Weapons/EsxAxisBlock/AxisBlock.glb",
 "job": "examples/fo4-mesh-block/meshes/Weapons/EsxAxisBlock/AxisBlock.mesh.toml",
 "template": null,
 "output": "Meshes/Weapons/EsxAxisBlock/AxisBlock.nif"}

The report of the assets step has meshes. Each file has the report of nif import, and reused:

{"converted": 1, "reused": 0, "files": [
  {"model": "examples/fo4-mesh-block/meshes/Weapons/EsxAxisBlock/AxisBlock.glb",
   "job": "examples/fo4-mesh-block/meshes/Weapons/EsxAxisBlock/AxisBlock.mesh.toml",
   "output": "Meshes/Weapons/EsxAxisBlock/AxisBlock.nif", "scale": 69.99124908447266, "nodes": 2,
   "shapes": [{"name": "Body:0", "vertices": 72, "triangles": 36, "tangents": "calculated",
     "material": "Materials\\Weapons\\EsxAxisBlock\\AxisBlock.bgsm", "textures_from_material": true}],
   "connect_points": {"parents": ["P-Sight"], "children": ["C-Muzzle"]},
   "warnings": [], "blocks": 10, "bytes": 3882, "template": null, "reused": false}]}

The example shows one of the two shapes and a part of its fields.

Subject Rule
The job file <name>.mesh.toml beside the model. See The job file.
Defaults of the project The table [meshes] of esx.toml. scale is for a job file with no scale key when the model file has no scale of its own. tangents is for a job file with no tangents key. folder names another folder than meshes.
Material files The build reads a material file from the asset folders of the project, and then from the Data folder and the archives of the game. It copies the texture paths into the texture set of the shape. A path that names no file gives the warning MESH_MATERIAL_NOT_FOUND.
A template template and [collision] from of the job file are Data paths. The build finds the mesh in the asset folders of the project, then in the Data folder and the archives of the game, then below the folder of the job file. template_file and from_file name a file from the folder of the job file. A file in an asset folder also goes into the release, so keep a template that the release does not need outside the asset folders. The report of the mesh has template and collision. See Fill a template.
Warnings Each warning of a conversion is a warning of the assets step. Its message starts with the path of the mesh.
A job that fails The build stops. error.details.step is assets, error.details.reason is the code of the job (for example MODEL_NO_UV or MESH_JOB_INVALID), and the message names the model. The stage stays as it was.
Two sources A model and a mesh of an asset folder with the same output path are the error MESH_TWO_SOURCES. Two models with one output path, for example Barrel.glb and Barrel.gltf, are the same error. Letter case is ignored. A dry run finds it also.

What the build converts again

A converted mesh stays in build/cache/meshes/<key>.nif, and the stage gets a hard link. The key is the SHA-256 of these inputs:

  • the model, and each .bin file of a .gltf model;
  • the job file;
  • the template and the collision source that the job file names;
  • each material file that the conversion read;
  • scale and tangents of the [meshes] table;
  • the output path, and the version of esx.

A build converts a model only when one of them changed. reused of the report counts the meshes that came from the cache, and a mesh from the cache gives its warnings again. esx build --full removes the cache.

The example project

examples/fo4-mesh-block/ in the repository is a complete project: the model of a block with two shapes, its job file, two material files, three textures, and an item file that makes a copy of the 10mm pistol with the block as its muzzle part. Its README gives the commands for the build, for the pictures and for the game test.

A game test of the example on Fallout 4 1.11.240 showed the block at the muzzle with its texture. The letters of the right side, of the top and of the front end were not mirrored and pointed to the correct side, and the vertex colors of the second shape changed the color of its texture.

Check a weapon

plugin check-weapons finds faults of a weapon before a game test: two parts on one slot, a slot that no part gives, a part with no recipe or no loose mod, and a mesh point with no partner. It reads the plugin, its masters and the meshes, and it starts no game.

esx --data '/path/to/Fallout 4/Data' plugin check-weapons build/release/p1.esp
ServicePistol [WEAP:FE000801] Service pistol (p1.esp)
  Slots
  SLOT               PART                     DEFAULT  RECIPE                      COMPONENTS  PERKS  LOOSE MOD
  ap_WeaponMaterial  Weapon_Material_Default  -        co_Weapon_Material_Default  -           -      -
  ap_gun_Barrel      ServicePistolBarrel      yes      -                           -           -      -
  ap_gun_Barrel      ServicePistolBarrelLong  yes      -                           -           -      -
  ap_gun_Grip        ServicePistolGrip        yes      -                           -           -      -
  ap_gun_Mag         ServicePistolMag         yes      -                           -           -      -
  ap_gun_Muzzle      ServicePistolMuzzle      yes      -                           -           -      -
  ap_gun_Muzzle      ServicePistolSuppressor  yes      -                           -           -      -
  ap_gun_Scope       ServicePistolScope       yes      -                           -           -      -
  ap_gun_receiver    ServicePistolReceiver    yes      -                           -           -      -
  Combinations
    0 (no name), default: ap_gun_receiver=ServicePistolReceiver, ap_gun_Grip=ServicePistolGrip, ap_gun_Barrel=ServicePistolBarrel, ap_gun_Barrel=ServicePistolBarrelLong, ap_gun_Mag=ServicePistolMag, ap_gun_Scope=ServicePistolScope, ap_gun_Muzzle=ServicePistolMuzzle, ap_gun_Muzzle=ServicePistolSuppressor
  Findings: 6
    error   WEAPON_SLOT_TWO_PARTS ServicePistol: the parts ServicePistolBarrel, ServicePistolBarrelLong have the same attach point ap_gun_Barrel. A slot holds one part (combination 0)
    error   WEAPON_SLOT_TWO_PARTS ServicePistol: the parts ServicePistolMuzzle, ServicePistolSuppressor have the same attach point ap_gun_Muzzle. A slot holds one part (combination 0)
    warning WEAPON_PART_NO_RECIPE ServicePistol: the part ServicePistolBarrel of the slot ap_gun_Barrel has no recipe (a COBJ with the part in CNAM). The workbench does not show it
    warning WEAPON_PART_NO_RECIPE ServicePistol: the part ServicePistolBarrelLong of the slot ap_gun_Barrel has no recipe (a COBJ with the part in CNAM). The workbench does not show it
    warning WEAPON_PART_NO_RECIPE ServicePistol: the part ServicePistolMuzzle of the slot ap_gun_Muzzle has no recipe (a COBJ with the part in CNAM). The workbench does not show it
    warning WEAPON_PART_NO_RECIPE ServicePistol: the part ServicePistolSuppressor of the slot ap_gun_Muzzle has no recipe (a COBJ with the part in CNAM). The workbench does not show it

This weapon came from an item file with two barrels and two muzzles. The build put the four parts into the default combination, and release check reported 0 issues.

Without a weapon argument the command checks each WEAP record of the plugin. A weapon argument is an editor ID or a FormID. The exit code is 0. With --fail-on-issues the exit code is 7 when a finding is an error.

The report uses these terms:

  • A part fits a weapon when one keyword of its MNAM is in the keywords of the weapon. The table Slots has each part that fits, by attach point.
  • The slots of a combination are the APPR keywords of the weapon and the DATA\Attach Parent Slots of each part that the weapon can hold.
  • A combination with a parent combination has the parts of the parent. A part replaces the part of the parent on the same attach point.
  • A mod collection is one include. It gives the parent slots and the mesh points of each member.
  • The meshes of a combination are the model of the weapon and the model of each part.

In the JSON output each weapon has slots, combinations and findings. A finding has code, severity, weapon, combination, combinations, part, mesh, block and message. The same finding in two combinations is one finding with the two indexes in combinations. The top level has findings for a finding with no weapon, counts and codes.

Code Type Meaning
WEAPON_SLOT_TWO_PARTS Error Two includes of one combination have the same attach point.
WEAPON_PART_FORM_TYPE Error DATA\Form Type of an include is not Weapon.
WEAPON_PART_NOT_FOUND Error The object template includes an OMOD that no loaded plugin has.
WEAPON_RECIPE_TARGETS_LOOSE_MOD Error A COBJ of the plugin has a MISC with the keyword ObjectTypeLooseMod in CNAM. The recipe of a part has the OMOD in CNAM.
WEAPON_CONNECT_PARENT_NODE Error A parent point has a Parent name that is not empty and is not the name of a node of its mesh.
WEAPON_PART_FILTER Warning An include does not fit the weapon, so the workbench does not show it for this weapon. It is a note when MNAM is empty.
WEAPON_SLOT_UNREACHABLE Warning The attach point of an include is not a slot of the combination.
WEAPON_DEFAULT_COMBINATION Warning Two or more combinations have Default = True. It is a note when no combination has it. esx uses the first combination then.
WEAPON_PART_NO_RECIPE Warning A part of the plugin fits the weapon, its slot has two or more parts, and no COBJ has it in CNAM.
WEAPON_SLOT_NO_RETURN Warning In a slot, a part has a recipe and the default part has none. The player cannot go back to the default part.
WEAPON_PART_NO_LOOSE_MOD Warning A part of the plugin has a recipe with components and no LNAM.
WEAPON_LOOSE_MOD_SHARED Warning Two parts have the same LNAM record.
WEAPON_LOOSE_MOD_KEYWORD Warning An LNAM record of the plugin does not have the keyword ObjectTypeLooseMod.
WEAPON_CONNECT_NO_PARENT Warning The mesh of a part has the child point C-X, and no mesh of the combination has the parent point P-X.
WEAPON_MESH_NO_CHILD_POINT Warning The mesh of a part has no child point.
WEAPON_MESH_MISSING, WEAPON_PART_MESH_MISSING Warning A mesh has no file, or esx cannot read it. The mesh rules do not run for that file.
WEAPON_NODE_MISSING Warning With --reference: the mesh does not have a node of the vanilla mesh of the same slot.
WEAPON_SLOT_NO_POINT Note A part has an attach parent slot, the parts of that slot have child points, and the mesh of the part has no parent point with one of those names.
WEAPON_NODE_NEW Note With --reference: a node of the mesh is in no mesh of the reference weapon.
WEAPON_NO_OBJECT_TEMPLATE Note The weapon has no object template.

Compare the nodes with a vanilla weapon

A weapon that uses the animations of a vanilla weapon needs the nodes that those animations move. --reference WEAPON=VANILLA compares the meshes of the default combination of the two weapons, slot by slot, and the two weapon models. The vanilla weapon must be in a loaded plugin.

esx --data '/path/to/Fallout 4/Data' plugin check-weapons build/release/p1.esp --reference ServicePistol=10mm

The names are equal without case. The first node of a mesh is its root, and the command does not compare it.

What the rules come from

Each rule was run on the 252 weapons of Fallout4.esm and on the 16 weapons of the nine Creation Club plugins of one installation. No vanilla weapon has an error. Vanilla weapons do have warnings, and a warning is a fact to examine, not a fault:

  • WEAPON_PART_FILTER: 20 weapons of Fallout4.esm have the warning. Most are weapons of robots and companions that use the parts of a different weapon. 13 weapons have the note: parts with an empty MNAM, such as mod_UniversalOffset_Range_BoltAction, are in the templates of the hunting rifle and of the combat shotgun.
  • WEAPON_SLOT_UNREACHABLE: 16 weapons. The weapons of the Protectron have no APPR. The 10mm has a mod collection on ap_gun_Sight, and no part gives that slot. The LaserMusket has mod_Null_Muzzle in combinations where no part gives ap_gun_Muzzle.
  • WEAPON_DEFAULT_COMBINATION: 11 weapons have no default combination. The CombatRifle is one of them.
  • WEAPON_CONNECT_NO_PARENT: 15 weapons. 13 are robot weapons and one is the test weapon AAA_StandardGun. The other is the Baton: Stunpack.nif has the child point c-MeleeMod, and the model Baton_1.nif has p-MeleeMod001.

The point rules compare names: the child point C-X goes to the parent point P-X. This is what the vanilla meshes show. No game test proves that the game uses the names in this way, so the two rules that need the name of a partner are a warning and a note. Of the 943 weapon meshes of Fallout4 - Meshes.ba2, each parent point with a Parent name has a node with that name, so WEAPON_CONNECT_PARENT_NODE is an error. Ten of those meshes have a child point that starts with P-, so the command reads P-Barrel in a child list as C-Barrel. A mesh with two child points is correct when one of them has a partner.

The command does not read geometry, skin data or collision, and it does not prove that the workbench shows a part.

Export a model

nif export writes a model file from a mesh. The model file is glTF 2.0, and Blender reads it with no add-on. The command reads a file on disk, so extract a mesh of the game first:

esx resource extract 'Meshes/Weapons/10mmPistol/10MMPistol.nif' -o Meshes/Weapons/10mmPistol/10MMPistol.nif
esx nif export Meshes/Weapons/10mmPistol/10MMPistol.nif -o work/10MMPistol.glb --job
esx nif export Meshes/Weapons/10mmPistol/10MMPistol.nif -o work/Units.gltf --scale 1 --shape 'Pistol10mmReceiver:0'

The extension of -o selects the form. .glb is one binary file. .gltf is a JSON file with a .bin file beside it. The two commands do not make a folder, so work and the folder of the extracted mesh must exist.

The model has these parts:

Part of the mesh Part of the model
A node block A node with the same name, translation, rotation and scale. A node whose block type is not NiNode has the type in extras.esx.block.
A shape A node with the name of the shape and one mesh of one primitive: positions, normals, tangents, UVs, vertex colors and triangles.
A shape with a segment table The vertex attribute _ESX_SEGMENT of the primitive, and extras.esx.segments of the mesh. See Segments.
A shape with a skin The node of the shape has a skin. The joints are the bone nodes, the inverse bind matrix of a joint is the skin to bone transform, and JOINTS_0 and WEIGHTS_0 have the bone indices and the weights. See Skinned meshes.
A parent connect point A node with no mesh and no child, with the name of the point, below the node that the point names.
The child connect points The names, in extras.esx.connect_children of the root node.
A material path One material for the shapes that have this path. Its name is the file name of the path with no extension. extras.esx.material has the path, and extras.esx.textures has the texture paths of the mesh.
An alpha property alphaMode BLEND or MASK of the material. extras.esx.alpha has the flags and the threshold. Two shapes with one path and different alpha values get two materials, and the second name ends with _2.

The model has no image, so Blender shows each shape with one color.

A model file has other axes than the game: the game point (x, y, z) is the model point (x, z, -y). Blender converts the axes again on import, so the Blender scene has the axes of the game: Y is forward and Z is up. --scale N is the count of game units for one unit of the model. The default is 69.99125, which makes one unit of the model 1 meter. --scale 1 keeps game units. The value is in asset.extras.esx.scale of the model.

The report of the first export command, with one of the 6 shapes and two of the 10 texture paths:

{"input": "Meshes/Weapons/10mmPistol/10MMPistol.nif", "output": "work/10MMPistol.glb", "job": "work/10MMPistol.mesh.toml",
 "written": ["work/10MMPistol.glb", "work/10MMPistol.mesh.toml"], "bytes": 107915, "scale": 69.99125, "nodes": 29,
 "shapes": [{"block": 10, "name": "Pistol10mmBolt:0", "vertices": 576, "triangles": 600, "material": "10mmPistol", "segments": null}],
 "vertices": 1790, "triangles": 1818,
 "materials": [{"name": "10mmPistol", "path": "materials\\Weapons\\10mmPistol\\10mmPistol.BGSM",
   "textures": ["textures\\Weapons\\10mmPistol\\10mmPistol02_d.dds", "textures\\Weapons\\10mmPistol\\10mmPistol02_n.dds"]}],
 "skins": [],
 "connect_points": {"parents": ["P-Dot", "P-Mag", "P-ProjectileNode", "P-Barrel", "P-Grip", "P-Scope", "P-Casing"], "children": ["C-Receiver"]},
 "skipped": [], "warnings": []}

nodes counts each node of the model: 16 node blocks, 6 shapes and 7 parent connect points.

Field Content
skipped Each node and each shape of the mesh that is not in the model, with its block, its type, its name and the reason. A shape with a data size of 0 has no geometry in the mesh. A block that no chain of children from the root reaches is also not in the model.
shapes Each shape of the model. vertices is the count in the model. segments is null, or the segment table of the shape: the count of segments, the total with the subsegments, the ssf path and the count of vertex copies. See Segments.
warnings MESH_POINT_PARENT_NOT_FOUND: a parent connect point names a node that the mesh does not have, and the point is below the root. MESH_ROTATION_NOT_EXACT: a matrix of the mesh is not a rotation, and the model has the nearest rotation.
skins One entry for each shape with a skin: the name of the shape, and the names of its bones in the order of its bone list.

--shape NAME keeps the shapes with this name. Repeat it for more names. The model keeps each node and each connect point. A name that the mesh does not have gives exit code 3 and the list of the names.

--job also writes the job file <output name>.mesh.toml beside the model:

# The job file of `esx nif import` for 10MMPistol.glb.
scale = 69.99125
template = "Meshes/Weapons/10mmPistol/10MMPistol.nif"

[materials]
10mmPistol = "materials\\Weapons\\10mmPistol\\10mmPistol.BGSM"

[connect]
children = ["C-Receiver"]

Blender does not keep asset.extras, and it keeps the other extras values only with the export option “Custom Properties”. The job file keeps the scale, the material paths and the names of the child connect points for the way back. The source mesh is the key template with its Data path when the mesh is in a folder with the name Meshes. Else it is the key template_file with the path from the job file.

The command follows the save rules: a file that exists needs --overwrite, and a path in a game folder is refused. The rules apply to the model, to its .bin file and to the job file, and the command checks them before it writes the first file.

Some values change in Blender 4.5:

  • Positions, UVs and triangles come back equal. Blender makes each normal a unit vector, so a normal comes back within 1 of 255.
  • Blender writes tangents only with the export option “Tangents”.
  • Blender keeps a vertex color as an sRGB byte: 73 of the 256 byte values come back changed by 1. It writes vertex colors only with the export option “Vertex Color: Active”, or when the material uses them.
  • Blender writes the children of a node in name order.
  • Blender can divide a vertex in two: the 1,790 vertices of the pistol came back as 1,792.

Each of the 943 vanilla weapon meshes exports to a correct file: 2,759 shapes with 2,277,906 vertices. Each position, UV and normal of those files gives the bytes of the mesh again through the two rules.

From a model to the game

Two example projects of the repository go the full route with no other tool than esx and the program that writes the model: a rigid weapon part and a piece of armor with a skin. A game test on Fallout 4 1.11.240 proved each one. The README of each example has each command and what each picture of the game showed.

Subject Rigid mesh Skinned mesh
Project examples/fo4-mesh-block/ examples/fo4-armor-band/
Model meshes/Weapons/EsxAxisBlock/AxisBlock.glb: 2 shapes, 96 vertices, 48 triangles meshes/Armor/EsxArmBand/ArmBand.glb: 1 shape, 89 vertices, 108 triangles, 3 joints
Job file Two material paths and the child connect point C-Muzzle One material path and the key skeleton
Mesh of the build 10 blocks, two BSTriShape blocks and the connect point blocks 9 blocks, one BSSubIndexTriShape with a skin, 3 bone nodes and the default segment table
Item file A copy of the weapon 10mm with the mesh as the model of the muzzle part A copy of the armor Armor_DCGuard_LArmLower with the mesh in [addon] male
Game proof The block is at the muzzle. The letters of three faces are not mirrored. The band is around the left forearm, also when the player lifts the fists.

The steps are the same for the two projects.

  1. Write the model as a glTF 2.0 file. Blender does this with File, Export, glTF 2.0: see Blender. The two examples use a program of the repository:

    cargo run -p esx-model --example axis_block -- examples/fo4-mesh-block/meshes/Weapons/EsxAxisBlock/AxisBlock.glb
    cargo run -p esx-model --example arm_band -- examples/fo4-armor-band/meshes/Armor/EsxArmBand/ArmBand.glb

    A joint of a skinned model has the name of a bone of the actor, for example LArm_ForeArm1_skin.

  2. Put the model into meshes/ of the project with the path of its mesh, and write the job file <name>.mesh.toml beside it. The job file of the arm band:

    skeleton = "Meshes/Actors/Character/CharacterAssets/skeleton.nif"
    
    [materials]
    ArmBand = "Materials/Armor/EsxArmBand/ArmBand.bgsm"
  3. Make the textures and the material in assets/. The two commands do not make a folder, so make the folders first:

    mkdir -p assets/Textures/Armor/EsxArmBand assets/Materials/Armor/EsxArmBand
    esx texture convert ArmBand_d.png --role diffuse -o assets/Textures/Armor/EsxArmBand/ArmBand_d.dds
    esx material create bgsm -o assets/Materials/Armor/EsxArmBand/ArmBand.bgsm
    esx material set assets/Materials/Armor/EsxArmBand/ArmBand.bgsm textures/diffuse Armor/EsxArmBand/ArmBand_d.dds -o assets/Materials/Armor/EsxArmBand/ArmBand.bgsm --overwrite
  4. Name the mesh in an item file. The path is relative to Meshes:

    kind = "armor"
    name = "Arm band"
    from = "Armor_DCGuard_LArmLower"
    
    [addon]
    male = 'Armor\EsxArmBand\ArmBand.nif'
  5. Build. The assets step converts the model, and the check step reads the mesh as each other mesh:

    esx build examples/fo4-armor-band

    The build reports "meshes": {"converted": 1, "reused": 0, ...} and 0 issues of the release check for each of the two examples.

  6. Look at the mesh with no game start:

    cd examples/fo4-armor-band/build/stage
    esx nif shapes Meshes/Armor/EsxArmBand/ArmBand.nif --vertices
    esx render mesh Meshes/Armor/EsxArmBand/ArmBand.nif --sheet --size 320x320 -o ArmBand.png

    esx render mesh draws a skinned mesh in the space of its skin, with no bones.

  7. Test in the game. See Test a mod in the game.

    esx probe plan examples/fo4-armor-band
    esx probe run examples/fo4-armor-band/build/test-plan.toml -o /path/to/evidence

    The plan of a weapon draws the weapon and makes pictures around it. The plan of an armor equips it, expects worn and model_loaded, and makes four pictures around the body. Look at each picture.

What the game test of the arm band showed

The tests were on 5 October 2026 with the probe 0.2.0. A vanilla forearm armor in the same views was the control. The first runs had the band as a BSTriShape with no segment table. The last run had the mesh of this version, a BSSubIndexTriShape with the default segment table, and its pictures show the band at the same place.

Question Answer
Does a new shape with a skin show on a body? Yes, as a BSTriShape with no segment table and as a BSSubIndexTriShape with the default segment table. Each run made 27 pictures of the band, at rest and with lifted fists. The band was around the left forearm in each picture that shows the arm.
Does the game use the transform of a bone node in the mesh? No. A band with the key skeleton and a band whose bone nodes were at the origin of the mesh were at the same place on the arm. The game finds the bone of the actor by the name of the node.
Where must the vertices of a skinned model be? At the place that the skin to bone transforms give. For each bone, skin to bone * position is the position in the space of the bone of the actor. The band is a tube around the X axis of the model, each joint is on that axis, and its inverse bind matrix is the reverse of its translation. The X axis of a forearm bone points to the hand, so the tube is around the forearm. The offset of 120.84 game units of the vanilla armor meshes is not necessary.
Are the winding and the UV map of a skinned shape correct? Yes. With a material with one side, each cell of the texture showed its outside. The letters were not mirrored, and the half with the letter E was at the elbow.

The two examples do not prove a model that a person made in a modelling program, a mesh that fits a body, an effect shader, a controller, a first person mesh and collision from geometry.

A third example, examples/fo4-ammo-display/, uses the job key behavior_graph. Its model is a row of six blocks, the base model of a copy of the .44 pistol, and its behavior source makes the graph that shows one block for each loaded round. A game test on 7 October 2026 with the probe 0.3.0 showed 6, 4 and 1 blocks in first person and 2 blocks in third person. See The graph of the weapon model.